CMakeLists.txt 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. cmake_minimum_required(VERSION 3.3)
  2. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) # main (top) cmake dir
  3. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
  4. # CMake useful variables
  5. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  6. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
  7. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
  8. # Set the name of your project here
  9. project("sotfloat")
  10. # Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
  11. set(VERSION "3e")
  12. include(Common)
  13. set(SPECIALIZATION RISCV)
  14. add_definitions(
  15. -DSOFTFLOAT_ROUND_ODD
  16. -DINLINE_LEVEL=5
  17. -DSOFTFLOAT_FAST_DIV32TO16
  18. -DSOFTFLOAT_FAST_DIV64TO32
  19. -DSOFTFLOAT_FAST_INT64
  20. # -DTHREAD_LOCAL=__thread
  21. )
  22. set(LIB_HEADERS source/include/softfloat.h source/include/softfloat_types.h)
  23. set(PRIMITIVES
  24. source/s_eq128.c
  25. source/s_le128.c
  26. source/s_lt128.c
  27. source/s_shortShiftLeft128.c
  28. source/s_shortShiftRight128.c
  29. source/s_shortShiftRightJam64.c
  30. source/s_shortShiftRightJam64Extra.c
  31. source/s_shortShiftRightJam128.c
  32. source/s_shortShiftRightJam128Extra.c
  33. source/s_shiftRightJam32.c
  34. source/s_shiftRightJam64.c
  35. source/s_shiftRightJam64Extra.c
  36. source/s_shiftRightJam128.c
  37. source/s_shiftRightJam128Extra.c
  38. source/s_shiftRightJam256M.c
  39. source/s_countLeadingZeros8.c
  40. source/s_countLeadingZeros16.c
  41. source/s_countLeadingZeros32.c
  42. source/s_countLeadingZeros64.c
  43. source/s_add128.c
  44. source/s_add256M.c
  45. source/s_sub128.c
  46. source/s_sub256M.c
  47. source/s_mul64ByShifted32To128.c
  48. source/s_mul64To128.c
  49. source/s_mul128By32.c
  50. source/s_mul128To256M.c
  51. source/s_approxRecip_1Ks.c
  52. source/s_approxRecip32_1.c
  53. source/s_approxRecipSqrt_1Ks.c
  54. source/s_approxRecipSqrt32_1.c
  55. )
  56. set(SPECIALIZE
  57. source/${SPECIALIZATION}/softfloat_raiseFlags.c
  58. source/${SPECIALIZATION}/s_f16UIToCommonNaN.c
  59. source/${SPECIALIZATION}/s_commonNaNToF16UI.c
  60. source/${SPECIALIZATION}/s_propagateNaNF16UI.c
  61. source/${SPECIALIZATION}/s_f32UIToCommonNaN.c
  62. source/${SPECIALIZATION}/s_commonNaNToF32UI.c
  63. source/${SPECIALIZATION}/s_propagateNaNF32UI.c
  64. source/${SPECIALIZATION}/s_f64UIToCommonNaN.c
  65. source/${SPECIALIZATION}/s_commonNaNToF64UI.c
  66. source/${SPECIALIZATION}/s_propagateNaNF64UI.c
  67. source/${SPECIALIZATION}/extF80M_isSignalingNaN.c
  68. source/${SPECIALIZATION}/s_extF80UIToCommonNaN.c
  69. source/${SPECIALIZATION}/s_commonNaNToExtF80UI.c
  70. source/${SPECIALIZATION}/s_propagateNaNExtF80UI.c
  71. source/${SPECIALIZATION}/f128M_isSignalingNaN.c
  72. source/${SPECIALIZATION}/s_f128UIToCommonNaN.c
  73. source/${SPECIALIZATION}/s_commonNaNToF128UI.c
  74. source/${SPECIALIZATION}/s_propagateNaNF128UI.c
  75. )
  76. set(OTHERS
  77. source/s_roundToUI32.c
  78. source/s_roundToUI64.c
  79. source/s_roundToI32.c
  80. source/s_roundToI64.c
  81. source/s_normSubnormalF16Sig.c
  82. source/s_roundPackToF16.c
  83. source/s_normRoundPackToF16.c
  84. source/s_addMagsF16.c
  85. source/s_subMagsF16.c
  86. source/s_mulAddF16.c
  87. source/s_normSubnormalF32Sig.c
  88. source/s_roundPackToF32.c
  89. source/s_normRoundPackToF32.c
  90. source/s_addMagsF32.c
  91. source/s_subMagsF32.c
  92. source/s_mulAddF32.c
  93. source/s_normSubnormalF64Sig.c
  94. source/s_roundPackToF64.c
  95. source/s_normRoundPackToF64.c
  96. source/s_addMagsF64.c
  97. source/s_subMagsF64.c
  98. source/s_mulAddF64.c
  99. source/s_normSubnormalExtF80Sig.c
  100. source/s_roundPackToExtF80.c
  101. source/s_normRoundPackToExtF80.c
  102. source/s_addMagsExtF80.c
  103. source/s_subMagsExtF80.c
  104. source/s_normSubnormalF128Sig.c
  105. source/s_roundPackToF128.c
  106. source/s_normRoundPackToF128.c
  107. source/s_addMagsF128.c
  108. source/s_subMagsF128.c
  109. source/s_mulAddF128.c
  110. source/softfloat_state.c
  111. source/ui32_to_f16.c
  112. source/ui32_to_f32.c
  113. source/ui32_to_f64.c
  114. source/ui32_to_extF80.c
  115. source/ui32_to_extF80M.c
  116. source/ui32_to_f128.c
  117. source/ui32_to_f128M.c
  118. source/ui64_to_f16.c
  119. source/ui64_to_f32.c
  120. source/ui64_to_f64.c
  121. source/ui64_to_extF80.c
  122. source/ui64_to_extF80M.c
  123. source/ui64_to_f128.c
  124. source/ui64_to_f128M.c
  125. source/i32_to_f16.c
  126. source/i32_to_f32.c
  127. source/i32_to_f64.c
  128. source/i32_to_extF80.c
  129. source/i32_to_extF80M.c
  130. source/i32_to_f128.c
  131. source/i32_to_f128M.c
  132. source/i64_to_f16.c
  133. source/i64_to_f32.c
  134. source/i64_to_f64.c
  135. source/i64_to_extF80.c
  136. source/i64_to_extF80M.c
  137. source/i64_to_f128.c
  138. source/i64_to_f128M.c
  139. source/f16_to_ui32.c
  140. source/f16_to_ui64.c
  141. source/f16_to_i32.c
  142. source/f16_to_i64.c
  143. source/f16_to_ui32_r_minMag.c
  144. source/f16_to_ui64_r_minMag.c
  145. source/f16_to_i32_r_minMag.c
  146. source/f16_to_i64_r_minMag.c
  147. source/f16_to_f32.c
  148. source/f16_to_f64.c
  149. source/f16_to_extF80.c
  150. source/f16_to_extF80M.c
  151. source/f16_to_f128.c
  152. source/f16_to_f128M.c
  153. source/f16_roundToInt.c
  154. source/f16_add.c
  155. source/f16_sub.c
  156. source/f16_mul.c
  157. source/f16_mulAdd.c
  158. source/f16_div.c
  159. source/f16_rem.c
  160. source/f16_sqrt.c
  161. source/f16_eq.c
  162. source/f16_le.c
  163. source/f16_lt.c
  164. source/f16_eq_signaling.c
  165. source/f16_le_quiet.c
  166. source/f16_lt_quiet.c
  167. source/f16_isSignalingNaN.c
  168. source/f32_to_ui32.c
  169. source/f32_to_ui64.c
  170. source/f32_to_i32.c
  171. source/f32_to_i64.c
  172. source/f32_to_ui32_r_minMag.c
  173. source/f32_to_ui64_r_minMag.c
  174. source/f32_to_i32_r_minMag.c
  175. source/f32_to_i64_r_minMag.c
  176. source/f32_to_f16.c
  177. source/f32_to_f64.c
  178. source/f32_to_extF80.c
  179. source/f32_to_extF80M.c
  180. source/f32_to_f128.c
  181. source/f32_to_f128M.c
  182. source/f32_roundToInt.c
  183. source/f32_add.c
  184. source/f32_sub.c
  185. source/f32_mul.c
  186. source/f32_mulAdd.c
  187. source/f32_div.c
  188. source/f32_rem.c
  189. source/f32_sqrt.c
  190. source/f32_eq.c
  191. source/f32_le.c
  192. source/f32_lt.c
  193. source/f32_eq_signaling.c
  194. source/f32_le_quiet.c
  195. source/f32_lt_quiet.c
  196. source/f32_isSignalingNaN.c
  197. source/f64_to_ui32.c
  198. source/f64_to_ui64.c
  199. source/f64_to_i32.c
  200. source/f64_to_i64.c
  201. source/f64_to_ui32_r_minMag.c
  202. source/f64_to_ui64_r_minMag.c
  203. source/f64_to_i32_r_minMag.c
  204. source/f64_to_i64_r_minMag.c
  205. source/f64_to_f16.c
  206. source/f64_to_f32.c
  207. source/f64_to_extF80.c
  208. source/f64_to_extF80M.c
  209. source/f64_to_f128.c
  210. source/f64_to_f128M.c
  211. source/f64_roundToInt.c
  212. source/f64_add.c
  213. source/f64_sub.c
  214. source/f64_mul.c
  215. source/f64_mulAdd.c
  216. source/f64_div.c
  217. source/f64_rem.c
  218. source/f64_sqrt.c
  219. source/f64_eq.c
  220. source/f64_le.c
  221. source/f64_lt.c
  222. source/f64_eq_signaling.c
  223. source/f64_le_quiet.c
  224. source/f64_lt_quiet.c
  225. source/f64_isSignalingNaN.c
  226. source/extF80_to_ui32.c
  227. source/extF80_to_ui64.c
  228. source/extF80_to_i32.c
  229. source/extF80_to_i64.c
  230. source/extF80_to_ui32_r_minMag.c
  231. source/extF80_to_ui64_r_minMag.c
  232. source/extF80_to_i32_r_minMag.c
  233. source/extF80_to_i64_r_minMag.c
  234. source/extF80_to_f16.c
  235. source/extF80_to_f32.c
  236. source/extF80_to_f64.c
  237. source/extF80_to_f128.c
  238. source/extF80_roundToInt.c
  239. source/extF80_add.c
  240. source/extF80_sub.c
  241. source/extF80_mul.c
  242. source/extF80_div.c
  243. source/extF80_rem.c
  244. source/extF80_sqrt.c
  245. source/extF80_eq.c
  246. source/extF80_le.c
  247. source/extF80_lt.c
  248. source/extF80_eq_signaling.c
  249. source/extF80_le_quiet.c
  250. source/extF80_lt_quiet.c
  251. source/extF80_isSignalingNaN.c
  252. source/extF80M_to_ui32.c
  253. source/extF80M_to_ui64.c
  254. source/extF80M_to_i32.c
  255. source/extF80M_to_i64.c
  256. source/extF80M_to_ui32_r_minMag.c
  257. source/extF80M_to_ui64_r_minMag.c
  258. source/extF80M_to_i32_r_minMag.c
  259. source/extF80M_to_i64_r_minMag.c
  260. source/extF80M_to_f16.c
  261. source/extF80M_to_f32.c
  262. source/extF80M_to_f64.c
  263. source/extF80M_to_f128M.c
  264. source/extF80M_roundToInt.c
  265. source/extF80M_add.c
  266. source/extF80M_sub.c
  267. source/extF80M_mul.c
  268. source/extF80M_div.c
  269. source/extF80M_rem.c
  270. source/extF80M_sqrt.c
  271. source/extF80M_eq.c
  272. source/extF80M_le.c
  273. source/extF80M_lt.c
  274. source/extF80M_eq_signaling.c
  275. source/extF80M_le_quiet.c
  276. source/extF80M_lt_quiet.c
  277. source/f128_to_ui32.c
  278. source/f128_to_ui64.c
  279. source/f128_to_i32.c
  280. source/f128_to_i64.c
  281. source/f128_to_ui32_r_minMag.c
  282. source/f128_to_ui64_r_minMag.c
  283. source/f128_to_i32_r_minMag.c
  284. source/f128_to_i64_r_minMag.c
  285. source/f128_to_f16.c
  286. source/f128_to_f32.c
  287. source/f128_to_extF80.c
  288. source/f128_to_f64.c
  289. source/f128_roundToInt.c
  290. source/f128_add.c
  291. source/f128_sub.c
  292. source/f128_mul.c
  293. source/f128_mulAdd.c
  294. source/f128_div.c
  295. source/f128_rem.c
  296. source/f128_sqrt.c
  297. source/f128_eq.c
  298. source/f128_le.c
  299. source/f128_lt.c
  300. source/f128_eq_signaling.c
  301. source/f128_le_quiet.c
  302. source/f128_lt_quiet.c
  303. source/f128_isSignalingNaN.c
  304. source/f128M_to_ui32.c
  305. source/f128M_to_ui64.c
  306. source/f128M_to_i32.c
  307. source/f128M_to_i64.c
  308. source/f128M_to_ui32_r_minMag.c
  309. source/f128M_to_ui64_r_minMag.c
  310. source/f128M_to_i32_r_minMag.c
  311. source/f128M_to_i64_r_minMag.c
  312. source/f128M_to_f16.c
  313. source/f128M_to_f32.c
  314. source/f128M_to_extF80M.c
  315. source/f128M_to_f64.c
  316. source/f128M_roundToInt.c
  317. source/f128M_add.c
  318. source/f128M_sub.c
  319. source/f128M_mul.c
  320. source/f128M_mulAdd.c
  321. source/f128M_div.c
  322. source/f128M_rem.c
  323. source/f128M_sqrt.c
  324. source/f128M_eq.c
  325. source/f128M_le.c
  326. source/f128M_lt.c
  327. source/f128M_eq_signaling.c
  328. source/f128M_le_quiet.c
  329. source/f128M_lt_quiet.c
  330. )
  331. set(LIB_SOURCES ${PRIMITIVES} ${SPECIALIZE} ${OTHERS})
  332. # Define two variables in order not to repeat ourselves.
  333. set(LIBRARY_NAME softfloat)
  334. # Define the library
  335. add_library(${LIBRARY_NAME} ${LIB_SOURCES})
  336. set_property(TARGET ${LIBRARY_NAME} PROPERTY C_STANDARD 99)
  337. target_include_directories(${LIBRARY_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/build/Linux-x86_64-GCC)
  338. target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source/include ${CMAKE_CURRENT_SOURCE_DIR}/source/${SPECIALIZATION})
  339. # Set the build version. It will be used in the name of the lib, with corresponding
  340. # symlinks created. SOVERSION could also be specified for api version.
  341. set_target_properties(${LIBRARY_NAME} PROPERTIES
  342. VERSION ${VERSION}
  343. FRAMEWORK FALSE
  344. PUBLIC_HEADER "${LIB_HEADERS}"
  345. )
  346. # Says how and where to install software
  347. # Targets:
  348. # * <prefix>/lib/<libraries>
  349. # * header location after install: <prefix>/include/<project>/*.h
  350. # * headers can be included by C++ code `#<project>/Bar.hpp>`
  351. install(TARGETS ${LIBRARY_NAME}
  352. EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
  353. ARCHIVE DESTINATION lib COMPONENT libs # static lib
  354. LIBRARY DESTINATION lib COMPONENT libs # shared lib
  355. FRAMEWORK DESTINATION bin COMPONENT libs # for mac
  356. PUBLIC_HEADER DESTINATION include COMPONENT devel # headers for mac (note the different component -> different package)
  357. INCLUDES DESTINATION include # headers
  358. )