LocalSetup.cmake 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. #
  2. # LocalSetup.cmake
  3. #
  4. # This file contains further instructions to set up the DTOOL package
  5. # when using CMake. In particular, it creates the dtool_config.h
  6. # file based on the user's selected configure variables.
  7. #
  8. include(CheckCXXSourceCompiles)
  9. include(CheckCSourceRuns)
  10. include(CheckIncludeFileCXX)
  11. include(CheckFunctionExists)
  12. include(CheckTypeSize)
  13. include(TestBigEndian)
  14. include(TestForSTDNamespace)
  15. # Define if we have libjpeg installed.
  16. check_include_file_cxx(jpegint.h PHAVE_JPEGINT_H)
  17. # Check if this is a big-endian system.
  18. test_big_endian(WORDS_BIGENDIAN)
  19. # Check if the compiler supports namespaces.
  20. set(HAVE_NAMESPACE ${CMAKE_STD_NAMESPACE})
  21. # Define if fstream::open() accepts a third parameter for umask.
  22. #TODO make test case
  23. #$[cdefine HAVE_OPEN_MASK]
  24. # Define if we have lockf().
  25. #TODO make test case
  26. set(HAVE_LOCKF 1)
  27. # Check if we have a wchar_t type.
  28. check_type_size(wchar_t HAVE_WCHAR_T)
  29. # Check if we have a wstring type.
  30. check_cxx_source_compiles("
  31. #include <string>
  32. std::wstring str;
  33. int main(int argc, char *argv[]) { return 0; }
  34. " HAVE_WSTRING)
  35. # Define if the C++ compiler supports the typename keyword.
  36. #TODO make test case (I had one but it broke)
  37. set(HAVE_TYPENAME 1)
  38. # Define if we can trust the compiler not to insert extra bytes in
  39. # structs between base structs and derived structs.
  40. check_c_source_runs("
  41. struct A { int a; };
  42. struct B : public A { int b; };
  43. int main(int argc, char *argv[]) {
  44. struct B i;
  45. if ((size_t) &(i.b) == ((size_t) &(i.a)) + sizeof(struct A)) {
  46. return 0;
  47. } else {
  48. return 1;
  49. }
  50. }" SIMPLE_STRUCT_POINTERS)
  51. # Define if we have STL hash_map etc. available.
  52. # We're not using this functionality at the moment, it seems.
  53. set(HAVE_STL_HASH OFF)
  54. # Check if we have a gettimeofday() function.
  55. check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
  56. # Define if gettimeofday() takes only one parameter.
  57. check_cxx_source_compiles("
  58. #include <sys/time.h>
  59. int main(int argc, char *argv[]) {
  60. struct timeval tv;
  61. int result;
  62. result = gettimeofday(&tv);
  63. return 0;
  64. }" GETTIMEOFDAY_ONE_PARAM)
  65. # Check if we have getopt.
  66. check_function_exists(getopt HAVE_GETOPT)
  67. check_function_exists(getopt_long_only HAVE_GETOPT_LONG_ONLY)
  68. check_include_file_cxx(getopt.h PHAVE_GETOPT_H)
  69. # Define if you have ioctl(TIOCGWINSZ) to determine terminal width.
  70. #XXX can we make a test case for this that isn't dependent on
  71. # the current terminal? It might also be useful for Cygwin users.
  72. if(UNIX)
  73. set(IOCTL_TERMINAL_WIDTH 1)
  74. endif()
  75. # Do the system headers define a "streamsize" typedef?
  76. check_cxx_source_compiles("
  77. #include <ios>
  78. std::streamsize ss;
  79. int main(int argc, char *argv[]) { return 0; }
  80. " HAVE_STREAMSIZE)
  81. # Do the system headers define key ios typedefs like ios::openmode
  82. # and ios::fmtflags?
  83. #TODO make test case
  84. set(HAVE_IOS_TYPEDEFS 1)
  85. # Define if the C++ iostream library defines ios::binary.
  86. #TODO make test case
  87. #$[cdefine HAVE_IOS_BINARY]
  88. # Can we safely call getenv() at static init time?
  89. #TODO make test case? can we make a reliable one?
  90. #$[cdefine STATIC_INIT_GETENV]
  91. # Can we read the file /proc/self/[*] to determine our
  92. # environment variables at static init time?
  93. if(IS_LINUX)
  94. set(HAVE_PROC_SELF_EXE 1)
  95. set(HAVE_PROC_SELF_MAPS 1)
  96. set(HAVE_PROC_SELF_ENVIRON 1)
  97. set(HAVE_PROC_SELF_CMDLINE 1)
  98. endif()
  99. if(IS_FREEBSD)
  100. set(HAVE_PROC_CURPROC_FILE 1)
  101. set(HAVE_PROC_CURPROC_MAP 1)
  102. set(HAVE_PROC_CURPROC_CMDLINE 1)
  103. endif()
  104. # Do we have a global pair of argc/argv variables that we can read at
  105. # static init time? Should we prototype them? What are they called?
  106. #TODO make test case
  107. #$[cdefine HAVE_GLOBAL_ARGV]
  108. #$[cdefine PROTOTYPE_GLOBAL_ARGV]
  109. #$[cdefine GLOBAL_ARGV]
  110. #$[cdefine GLOBAL_ARGC]
  111. # Do we have all these header files?
  112. check_include_file_cxx(io.h PHAVE_IO_H)
  113. check_include_file_cxx(iostream PHAVE_IOSTREAM)
  114. check_include_file_cxx(malloc.h PHAVE_MALLOC_H)
  115. check_include_file_cxx(sys/malloc.h PHAVE_SYS_MALLOC_H)
  116. check_include_file_cxx(alloca.h PHAVE_ALLOCA_H)
  117. check_include_file_cxx(locale.h PHAVE_LOCALE_H)
  118. check_include_file_cxx(string.h PHAVE_STRING_H)
  119. check_include_file_cxx(stdlib.h PHAVE_STDLIB_H)
  120. check_include_file_cxx(limits.h PHAVE_LIMITS_H)
  121. check_include_file_cxx(minmax.h PHAVE_MINMAX_H)
  122. check_include_file_cxx(sstream PHAVE_SSTREAM)
  123. check_include_file_cxx(new PHAVE_NEW)
  124. check_include_file_cxx(sys/types.h PHAVE_SYS_TYPES_H)
  125. check_include_file_cxx(sys/time.h PHAVE_SYS_TIME_H)
  126. check_include_file_cxx(unistd.h PHAVE_UNISTD_H)
  127. check_include_file_cxx(utime.h PHAVE_UTIME_H)
  128. check_include_file_cxx(glob.h PHAVE_GLOB_H)
  129. check_include_file_cxx(dirent.h PHAVE_DIRENT_H)
  130. check_include_file_cxx(drfftw.h PHAVE_DRFFTW_H)
  131. check_include_file_cxx(sys/soundcard.h PHAVE_SYS_SOUNDCARD_H)
  132. check_include_file_cxx(ucontext.h PHAVE_UCONTEXT_H) #TODO doesn't work on OSX, use sys/ucontext.h
  133. check_include_file_cxx(linux/input.h PHAVE_LINUX_INPUT_H)
  134. check_include_file_cxx(stdint.h PHAVE_STDINT_H)
  135. check_include_file_cxx(typeinfo HAVE_RTTI)
  136. # Do we have Posix threads?
  137. #set(HAVE_POSIX_THREADS ${CMAKE_USE_PTHREADS_INIT})
  138. #/* Define if needed to have 64-bit file i/o */
  139. #$[cdefine __USE_LARGEFILE64]
  140. # Set LINK_ALL_STATIC if we're building everything as static libraries.
  141. if(BUILD_SHARED_LIBS)
  142. set(LINK_ALL_STATIC OFF)
  143. else()
  144. set(LINK_ALL_STATIC ON)
  145. endif()
  146. # Now go through all the packages and report whether we have them.
  147. message("")
  148. message("Configuring support for the following optional third-party packages:")
  149. if(HAVE_EIGEN)
  150. message("+ Eigen linear algebra library")
  151. if(LINMATH_ALIGN)
  152. message("+ (vectorization enabled in build)")
  153. else()
  154. message("- (vectorization NOT enabled in build)")
  155. endif()
  156. else()
  157. message("- Did not find Eigen linear algebra library")
  158. endif()
  159. if(HAVE_OPENSSL)
  160. message("+ OpenSSL")
  161. else()
  162. message("- Did not find OpenSSL")
  163. endif()
  164. if(HAVE_JPEG)
  165. message("+ libjpeg")
  166. else()
  167. message("- Did not find libjpeg")
  168. endif()
  169. if(HAVE_PNG)
  170. message("+ libpng")
  171. else()
  172. message("- Did not find libpng")
  173. endif()
  174. if(HAVE_TIFF)
  175. message("+ libtiff")
  176. else()
  177. message("- Did not find libtiff")
  178. endif()
  179. if(HAVE_TAR)
  180. message("+ libtar")
  181. else()
  182. message("- Did not find libtar")
  183. endif()
  184. if(HAVE_FFTW)
  185. message("+ fftw")
  186. else()
  187. message("- Did not find fftw")
  188. endif()
  189. if(HAVE_SQUISH)
  190. message("+ squish")
  191. else()
  192. message("- Did not find squish")
  193. endif()
  194. if(HAVE_CG)
  195. message("+ Nvidia Cg High Level Shading Language")
  196. else()
  197. message("- Did not find Nvidia Cg High Level Shading Language")
  198. endif()
  199. if(HAVE_CGGL)
  200. message("+ Cg OpenGL API")
  201. else()
  202. message("- Did not find Cg OpenGL API")
  203. endif()
  204. if(HAVE_CGDX8)
  205. message("+ Cg DX8 API")
  206. else()
  207. message("- Did not find Cg DX8 API")
  208. endif()
  209. if(HAVE_CGDX9)
  210. message("+ Cg DX9 API")
  211. else()
  212. message("- Did not find Cg DX9 API")
  213. endif()
  214. if(HAVE_CGDX10)
  215. message("+ Cg DX10 API")
  216. else()
  217. message("- Did not find Cg DX10 API")
  218. endif()
  219. if(HAVE_VRPN)
  220. message("+ VRPN")
  221. else()
  222. message("- Did not find VRPN")
  223. endif()
  224. if(HAVE_ZLIB)
  225. message("+ zlib")
  226. else()
  227. message("- Did not find zlib")
  228. endif()
  229. if(HAVE_RAD_MSS)
  230. message("+ Miles Sound System")
  231. else()
  232. message("- Did not find Miles Sound System")
  233. endif()
  234. if(HAVE_FMODEX)
  235. message("+ FMOD Ex sound library")
  236. else()
  237. message("- Did not find FMOD Ex sound library")
  238. endif()
  239. if(HAVE_OPENAL)
  240. message("+ OpenAL sound library")
  241. else()
  242. message("- Did not find OpenAL sound library")
  243. endif()
  244. if(HAVE_PHYSX)
  245. message("+ Ageia PhysX")
  246. else()
  247. message("- Did not find Ageia PhysX")
  248. endif()
  249. if(HAVE_SPEEDTREE)
  250. message("+ SpeedTree")
  251. else()
  252. message("- Did not find SpeedTree")
  253. endif()
  254. if(HAVE_GTK2)
  255. message("+ gtk+-2")
  256. else()
  257. message("- Did not find gtk+-2")
  258. endif()
  259. if(HAVE_FREETYPE)
  260. message("+ Freetype")
  261. else()
  262. message("- Did not find Freetype")
  263. endif()
  264. if(HAVE_WX)
  265. message("+ WxWidgets")
  266. else()
  267. message("- Did not find WxWidgets")
  268. endif()
  269. if(HAVE_FLTK)
  270. message("+ FLTK")
  271. else()
  272. message("- Did not find FLTK")
  273. endif()
  274. if(HAVE_GL)
  275. message("+ OpenGL")
  276. else()
  277. message("- Did not find OpenGL")
  278. endif()
  279. if(HAVE_GLES)
  280. message("+ OpenGL ES 1")
  281. else()
  282. message("- Did not find OpenGL ES 1")
  283. endif()
  284. if(HAVE_GLES2)
  285. message("+ OpenGL ES 2")
  286. else()
  287. message("- Did not find OpenGL ES 2")
  288. endif()
  289. if(HAVE_DX8)
  290. message("+ DirectX8")
  291. else()
  292. message("- Did not find DirectX8")
  293. endif()
  294. if(HAVE_DX9)
  295. message("+ DirectX9")
  296. else()
  297. message("- Did not find DirectX9")
  298. endif()
  299. if(HAVE_TINYDISPLAY)
  300. message("+ Tinydisplay")
  301. else()
  302. message("- Not building Tinydisplay")
  303. endif()
  304. if(HAVE_X11)
  305. message("+ X11")
  306. else()
  307. message("- Did not find X11")
  308. endif()
  309. if(HAVE_MESA)
  310. message("+ Mesa")
  311. else()
  312. message("- Did not find Mesa")
  313. endif()
  314. if(HAVE_OPENCV)
  315. message("+ OpenCV")
  316. else()
  317. message("- Did not find OpenCV")
  318. endif()
  319. if(HAVE_FFMPEG)
  320. message("+ FFMPEG")
  321. else()
  322. message("- Did not find FFMPEG")
  323. endif()
  324. if(HAVE_ODE)
  325. message("+ ODE")
  326. else()
  327. message("- Did not find ODE")
  328. endif()
  329. if(HAVE_AWESOMIUM)
  330. message("+ AWESOMIUM")
  331. else()
  332. message("- Did not find AWESOMIUM")
  333. endif()
  334. if(HAVE_MAYA)
  335. message("+ OpenMaya")
  336. else()
  337. message("- Did not find OpenMaya")
  338. endif()
  339. if(HAVE_FCOLLADA)
  340. message("+ FCollada")
  341. else()
  342. message("- Did not find FCollada")
  343. endif()
  344. if(HAVE_ASSIMP)
  345. message("+ Assimp")
  346. else()
  347. message("- Did not find Assimp")
  348. endif()
  349. if(HAVE_ARTOOLKIT)
  350. message("+ ARToolKit")
  351. else()
  352. message("- Did not find ARToolKit")
  353. endif()
  354. if(HAVE_ROCKET)
  355. if(HAVE_ROCKET_PYTHON)
  356. message("+ libRocket with Python bindings")
  357. else()
  358. message("+ libRocket without Python bindings")
  359. endif()
  360. else()
  361. message("- Did not find libRocket")
  362. endif()
  363. if(HAVE_BULLET)
  364. message("+ Bullet Physics")
  365. else()
  366. message("- Did not find Bullet Physics")
  367. endif()
  368. if(HAVE_VORBIS)
  369. message("+ libvorbis (Ogg Vorbis Decoder)")
  370. else()
  371. message("- Did not find libvorbis (Ogg Vorbis Decoder)")
  372. endif()
  373. message("")
  374. if(HAVE_INTERROGATE AND HAVE_PYTHON)
  375. message("Compilation will generate Python interfaces.")
  376. else()
  377. message("Configuring Panda WITHOUT Python interfaces.")
  378. endif()
  379. if(HAVE_THREADS)
  380. if(SIMPLE_THREADS)
  381. message("Compilation will include simulated threading support.")
  382. elseif(DO_PIPELINING)
  383. message("Compilation will include full, pipelined threading support.")
  384. else()
  385. message("Compilation will include nonpipelined threading support.")
  386. endif()
  387. else()
  388. message("Configuring Panda without threading support.")
  389. endif()
  390. message("")
  391. message("See dtool_config.h for more details about the specified configuration.")
  392. message("")
  393. # Generate dtool_config.h
  394. configure_file(dtool_config.h.in "${PROJECT_BINARY_DIR}/include/dtool_config.h")
  395. include_directories("${PROJECT_BINARY_DIR}/include")
  396. #install(FILES "${PROJECT_BINARY_DIR}/dtool_config.h" DESTINATION include/panda3d)