11from conan import ConanFile
22from conan .tools .cmake import CMake , CMakeToolchain , cmake_layout
3- from conan .tools .files import copy , get , mkdir
3+ from conan .tools .files import copy , get , mkdir , rmdir
4+ from conan .tools .apple import fix_apple_shared_install_name
45import glob
56import os
67import shutil
@@ -56,6 +57,9 @@ def configure(self):
5657 def layout (self ):
5758 cmake_layout (self , src_folder = "src" )
5859
60+ def build_requirements (self ):
61+ self .tool_requires ("cmake/[>=3.18]" )
62+
5963 def source (self ):
6064 get (self , ** self .conan_data ["sources" ][self .version ], strip_root = True )
6165
@@ -81,62 +85,51 @@ def package(self):
8185 copy (self , "LICENSE" , src = self .source_folder , dst = os .path .join (self .package_folder , "licenses" ))
8286 cmake = CMake (self )
8387 cmake .install ()
88+ rmdir (self , os .path .join (self .package_folder , "lib" , "cmake" ))
8489 if self .settings .os == "Windows" and self .options .shared :
8590 mkdir (self , os .path .join (self .package_folder , "bin" ))
8691 for dll_path in glob .glob (os .path .join (self .package_folder , "lib" , "*.dll" )):
8792 shutil .move (dll_path , os .path .join (self .package_folder , "bin" , os .path .basename (dll_path )))
93+ fix_apple_shared_install_name (self )
8894
8995 def package_info (self ):
90- self .cpp_info .components ["sundials_nvecmanyvector" ].libs = ["sundials_nvecmanyvector" ]
91- self .cpp_info .components ["sundials_nvecserial" ].libs = ["sundials_nvecserial" ]
92- self .cpp_info .components ["sundials_sunlinsolband" ].libs = ["sundials_sunlinsolband" ]
93- self .cpp_info .components ["sundials_sunlinsolband" ].requires = ["sundials_sunmatrixband" ]
94- self .cpp_info .components ["sundials_sunlinsoldense" ].libs = ["sundials_sunlinsoldense" ]
95- self .cpp_info .components ["sundials_sunlinsoldense" ].requires = ["sundials_sunmatrixdense" ]
96- self .cpp_info .components ["sundials_sunlinsolpcg" ].libs = ["sundials_sunlinsolpcg" ]
97- self .cpp_info .components ["sundials_sunlinsolspbcgs" ].libs = ["sundials_sunlinsolspbcgs" ]
98- self .cpp_info .components ["sundials_sunlinsolspfgmr" ].libs = ["sundials_sunlinsolspfgmr" ]
99- self .cpp_info .components ["sundials_sunlinsolspgmr" ].libs = ["sundials_sunlinsolspgmr" ]
100- self .cpp_info .components ["sundials_sunlinsolsptfqmr" ].libs = ["sundials_sunlinsolsptfqmr" ]
101- self .cpp_info .components ["sundials_sunmatrixband" ].libs = ["sundials_sunmatrixband" ]
102- self .cpp_info .components ["sundials_sunmatrixdense" ].libs = ["sundials_sunmatrixdense" ]
103- self .cpp_info .components ["sundials_sunmatrixsparse" ].libs = ["sundials_sunmatrixsparse" ]
104- self .cpp_info .components ["sundials_sunnonlinsolfixedpoint" ].libs = ["sundials_sunnonlinsolfixedpoint" ]
105- self .cpp_info .components ["sundials_sunnonlinsolnewton" ].libs = ["sundials_sunnonlinsolnewton" ]
106- if self .settings .os in ["Linux" , "FreeBSD" ]:
107- self .cpp_info .components ["sundials_nvecmanyvector" ].system_libs = ["m" ]
108- self .cpp_info .components ["sundials_nvecserial" ].system_libs = ["m" ]
109- self .cpp_info .components ["sundials_sunlinsolpcg" ].system_libs = ["m" ]
110- self .cpp_info .components ["sundials_sunlinsolspbcgs" ].system_libs = ["m" ]
111- self .cpp_info .components ["sundials_sunlinsolspfgmr" ].system_libs = ["m" ]
112- self .cpp_info .components ["sundials_sunlinsolspgmr" ].system_libs = ["m" ]
113- self .cpp_info .components ["sundials_sunlinsolsptfqmr" ].system_libs = ["m" ]
114- self .cpp_info .components ["sundials_sunmatrixband" ].system_libs = ["m" ]
115- self .cpp_info .components ["sundials_sunmatrixdense" ].system_libs = ["m" ]
116- self .cpp_info .components ["sundials_sunmatrixsparse" ].system_libs = ["m" ]
117- self .cpp_info .components ["sundials_sunnonlinsolfixedpoint" ].system_libs = ["m" ]
118- self .cpp_info .components ["sundials_sunnonlinsolnewton" ].system_libs = ["m" ]
119- if self .options .build_arkode :
120- self .cpp_info .components ["sundials_arkode" ].libs = ["sundials_arkode" ]
96+
97+ def _add_library (name ):
98+ # SundialsAddLibrary.cmake#377, where the first branch is always taken.
99+ library_suffix = "_static" if not self .options .shared and self .settings .compiler == "msvc" else ""
100+ self .cpp_info .components [name ].libs = ["sundials_" + name + library_suffix ]
101+ target_suffix = "_shared" if self .options .shared else "_static"
102+ self .cpp_info .components [name ].set_property ("cmake_target_name" , f"SUNDIALS::{ name } { target_suffix } " )
121103 if self .settings .os in ["Linux" , "FreeBSD" ]:
122- self .cpp_info .components ["sundials_arkode" ].system_libs = ["m" ]
104+ self .cpp_info .components [name ].system_libs .append ("m" )
105+ return self .cpp_info .components [name ]
106+
107+ _add_library ("core" )
108+ _add_library ("nvecserial" ).requires = ["core" ]
109+ _add_library ("nvecmanyvector" ).requires = ["core" ]
110+ _add_library ("sunmatrixdense" ).requires = ["core" ]
111+ _add_library ("sunmatrixband" ).requires = ["core" ]
112+ _add_library ("sunmatrixsparse" ).requires = ["core" ]
113+ _add_library ("sundomeigestpower" ).requires = ["core" ]
114+ _add_library ("sunlinsoldense" ).requires = ["core" , "sunmatrixdense" ]
115+ _add_library ("sunlinsolband" ).requires = ["core" , "sunmatrixband" ]
116+ _add_library ("sunlinsolpcg" ).requires = ["core" ]
117+ _add_library ("sunlinsolspbcgs" ).requires = ["core" ]
118+ _add_library ("sunlinsolspfgmr" ).requires = ["core" ]
119+ _add_library ("sunlinsolspgmr" ).requires = ["core" ]
120+ _add_library ("sunlinsolsptfqmr" ).requires = ["core" ]
121+ _add_library ("sunnonlinsolfixedpoint" ).requires = ["core" ]
122+ _add_library ("sunnonlinsolnewton" ).requires = ["core" ]
123+
124+ if self .options .build_arkode :
125+ _add_library ("arkode" ).requires = ["core" ]
123126 if self .options .build_cvode :
124- self .cpp_info .components ["sundials_cvode" ].libs = ["sundials_cvode" ]
125- if self .settings .os in ["Linux" , "FreeBSD" ]:
126- self .cpp_info .components ["sundials_cvode" ].system_libs = ["m" ]
127+ _add_library ("cvode" ).requires = ["core" ]
127128 if self .options .build_cvodes :
128- self .cpp_info .components ["sundials_cvodes" ].libs = ["sundials_cvodes" ]
129- if self .settings .os in ["Linux" , "FreeBSD" ]:
130- self .cpp_info .components ["sundials_cvodes" ].system_libs = ["m" ]
129+ _add_library ("cvodes" ).requires = ["core" ]
131130 if self .options .build_ida :
132- self .cpp_info .components ["sundials_ida" ].libs = ["sundials_ida" ]
133- if self .settings .os in ["Linux" , "FreeBSD" ]:
134- self .cpp_info .components ["sundials_ida" ].system_libs = ["m" ]
131+ _add_library ("ida" ).requires = ["core" ]
135132 if self .options .build_idas :
136- self .cpp_info .components ["sundials_idas" ].libs = ["sundials_idas" ]
137- if self .settings .os in ["Linux" , "FreeBSD" ]:
138- self .cpp_info .components ["sundials_idas" ].system_libs = ["m" ]
133+ _add_library ("idas" ).requires = ["core" ]
139134 if self .options .build_kinsol :
140- self .cpp_info .components ["sundials_kinsol" ].libs = ["sundials_kinsol" ]
141- if self .settings .os in ["Linux" , "FreeBSD" ]:
142- self .cpp_info .components ["sundials_kinsol" ].system_libs = ["m" ]
135+ _add_library ("kinsol" ).requires = ["core" ]
0 commit comments