Guest User

jmtrivial

a guest
Feb 22nd, 2008
288
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PROJECT(UnfoldSoftware)
  2.  
  3. SET(EXECUTABLE_OUTPUT_PATH bin/)
  4. MAKE_DIRECTORY(${EXECUTABLE_OUTPUT_PATH})
  5.  
  6. SET(LIBRARY_OUTPUT_PATH lib/)
  7. MAKE_DIRECTORY(${LIBRARY_OUTPUT_PATH})
  8.  
  9. SET(PYTHON_OUTPUT_PATH python/)
  10. SET(UnfoldSoftware_SOURCE_DIR src/)
  11. SET(SRC src/)
  12. SET(UnfoldSoftware_VERSION 0.0.1)
  13. SET(UnfoldSoftware_BINARY_DIR ${EXECUTABLE_OUTPUT_PATH})
  14. SET(UnfoldSoftware_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH})
  15. SET(UnfoldSoftware_DOC_DIR doc/)
  16. SET(UnfoldSoftware_CMAKE_DIR cmake/)
  17.  
  18. #--------------------------#
  19. #define include directories
  20. INCLUDE_DIRECTORIES(.
  21. ${SRC}/utils ${SRC}/algos ${SRC}/utils/files ${SRC}/utils/meshes
  22. ${SRC}/unfolding ${SRC}/unfolding/utils ${SRC}/unfolding/circlepacking
  23. ${SRC}/topology ${SRC}/display ${SRC}/cimg_plugins ${SRC}/apps/medical
  24. ${SRC}/unfolding/abf ${SRC}/include/opennl/extern ${SRC}/include/opennl/intern
  25. ${SRC}/include/opennl/superlu)
  26.  
  27.  
  28. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wunused -pedantic -ansi")
  29.  
  30. #look for libraries
  31. FIND_PACKAGE(X11)
  32. FIND_PACKAGE(Threads)
  33. FIND_PACKAGE(PNG)
  34. FIND_PACKAGE(JPEG)
  35. FIND_PACKAGE(GLUT)
  36. FIND_PACKAGE(LibXml2)
  37. FIND_PACKAGE(SWIG)
  38. INCLUDE(${UnfoldSoftware_CMAKE_DIR}/FindPOPT.cmake)
  39. INCLUDE(${UnfoldSoftware_CMAKE_DIR}/FindCIMG.cmake)
  40.  
  41. IF(NOT CIMG_FOUND)
  42. MESSAGE(FATAL_ERROR "CImg is not available. Precompilation failed")
  43. ENDIF(NOT CIMG_FOUND)
  44. IF(NOT POPT_FOUND)
  45. MESSAGE(FATAL_ERROR "libpopt is not available. Precompilation failed")
  46. ENDIF(NOT POPT_FOUND)
  47.  
  48.  
  49. INCLUDE_DIRECTORIES(${CIMG_INCLUDE_DIR} ${POPT_INCLUDE_DIR})
  50.  
  51. SET(LIBRARIES_X ${X11_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
  52. SET(LIBRARIES_SOFTWARE ${POPT_LIBRARIES})
  53.  
  54.  
  55. #add conditional include directories
  56. IF(LIBXML2_LIBRARIES)
  57. INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
  58. ELSE(LIBXML2_LIBRARIES)
  59. MESSAGE(STATUS "libxml2 not found. script interpreter will not be compiled")
  60. ENDIF(LIBXML2_LIBRARIES)
  61.  
  62. IF(X11_FOUND AND CMAKE_HAVE_THREADS_LIBRARY)
  63. INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
  64. ELSE(X11_FOUND AND CMAKE_HAVE_THREADS_LIBRARY)
  65. MESSAGE(STATUS "X11 not found. No graphical include")
  66. ENDIF(X11_FOUND AND CMAKE_HAVE_THREADS_LIBRARY)
  67.  
  68.  
  69. #--------------------------#
  70. # copy script
  71. IF(LIBXML2_LIBRARIES)
  72. EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy
  73. ${UnfoldSoftware_SOURCE_DIR}/utils/ScriptSchema.xsd
  74. ${EXECUTABLE_OUTPUT_PATH}/ScriptSchema.xsd)
  75. ENDIF(LIBXML2_LIBRARIES)
  76.  
  77.  
  78. #--------------------------#
  79. # Libraries
  80.  
  81.  
  82. IF(CIMG_FOUND)
  83. SET(CPP_UnfoldingTools_LIST ${SRC}/utils/files/MeshLoader.cpp
  84. ${SRC}/utils/files/MeshLoaderVRML.cpp ${SRC}/utils/files/FileTools.cpp
  85. ${SRC}/topology/Mesh.cpp ${SRC}/topology/MeshManipulator.cpp
  86. ${SRC}/topology/MeshPart.cpp ${SRC}/topology/MeshCut.cpp
  87. ${SRC}/unfolding/circlepacking/CPMethod.cpp ${SRC}/display/Display3D.cpp
  88. ${SRC}/topology/MeshPathes.cpp ${SRC}/topology/MeshPatches.cpp
  89. ${SRC}/display/DDisplay.cpp ${SRC}/display/DDScrollBar.cpp
  90. ${SRC}/display/DDBox.cpp ${SRC}/utils/MeshBExpr.cpp
  91. ${SRC}/display/DisplayGL.cpp ${SRC}/topology/MeshUncut.cpp
  92. ${SRC}/algos/Triangle.cpp ${SRC}/algos/ClusterGenerator.cpp
  93. ${SRC}/algos/Vertex.cpp ${SRC}/utils/files/MeshSaver.cpp
  94. ${SRC}/utils/SurfaceToolbox.cpp ${SRC}/utils/Messages.cpp
  95. ${SRC}/topology/Length.cpp ${SRC}/utils/Exception.cpp
  96. ${SRC}/utils/files/FileExceptions.cpp ${SRC}/algos/VerticesManipulator.cpp
  97. ${SRC}/utils/ColorChooser.cpp ${SRC}/topology/MeshList.cpp
  98. ${SRC}/utils/files/MeshSaverVRML.cpp ${SRC}/topology/SpaceSpliter.cpp
  99. ${SRC}/utils/files/MeshLoaderXYZ.cpp ${SRC}/utils/XMLSimpleNode.cpp
  100. ${SRC}/algos/MeshPrune.cpp ${SRC}/utils/IndentManager.cpp
  101. ${SRC}/apps/medical/Electrodes.cpp ${SRC}/topology/MeshRectPatcher.cpp
  102. ${SRC}/topology/Polygon.cpp ${SRC}/unfolding/Mapping2D3DList.cpp
  103. ${SRC}/unfolding/Mapping2D3D.cpp ${SRC}/unfolding/abf/ABFMethod.cpp
  104. ${SRC}/utils/PointSelector.cpp ${SRC}/utils/StringManipulation.cpp
  105. ${SRC}/topology/PointModifier.cpp ${SRC}/unfolding/MappingRegistration.cpp
  106. ${SRC}/topology/MeshMatcher.cpp ${SRC}/unfolding/MappingComparator.cpp
  107. ${SRC}/topology/MeshComparator.cpp ${SRC}/unfolding/MultiscaleUnfolding.cpp
  108. ${SRC}/unfolding/UnfoldingMethod.cpp ${SRC}/algos/MeshSmoother.cpp
  109. ${SRC}/topology/Mesh.h.gch)
  110.  
  111. # adding OpenNL files
  112. FILE(GLOB CPP_OpenNL_LIST ${SRC}/include/opennl/intern/*.c ${SRC}/include/opennl/superlu/*.c)
  113. SET(CPP_UnfoldingTools_LIST ${CPP_UnfoldingTools_LIST} ${CPP_OpenNL_LIST})
  114.  
  115. ADD_LIBRARY(UnfoldingTools SHARED ${CPP_UnfoldingTools_LIST})
  116. ENDIF(CIMG_FOUND)
  117.  
  118.  
  119.  
  120. #--------------------------#
  121. # Flags
  122. IF(LIBXML2_LIBRARIES)
  123. SET(UnfoldingTools_flags "${UnfoldingTools_flags} -DUSE_LIBXML")
  124. SET(python_binding_flags "${python_binding_flags} -DUSE_LIBXML")
  125. ENDIF(LIBXML2_LIBRARIES)
  126.  
  127. IF(GLUT_FOUND)
  128. SET(UnfoldingTools_flags "${UnfoldingTools_flags} -DUSE_GL")
  129. SET(python_binding_flags "${python_binding_flags} -DUSE_GL")
  130. SET(LIBRARIES_SOFTWARE ${LIBRARIES_SOFTWARE} ${GLUT_LIBRARIES})
  131. ENDIF(GLUT_FOUND)
  132.  
  133. IF(X11_FOUND AND CMAKE_HAVE_THREADS_LIBRARY)
  134. SET(UnfoldingTools_flags "${UnfoldingTools_flags} -DUSE_X")
  135. SET(python_binding_flags "${python_binding_flags} -DUSE_X")
  136. SET(LIBRARIES_CIMG ${LIBRARIES_CIMG} ${LIBRARIES_X})
  137. ENDIF(X11_FOUND AND CMAKE_HAVE_THREADS_LIBRARY)
  138.  
  139. IF(LIBXML2_LIBRARIES)
  140. SET(LIBRARIES_SOFTWARE ${LIBRARIES_SOFTWARE} ${LIBXML2_LIBRARIES})
  141. ENDIF(LIBXML2_LIBRARIES)
  142.  
  143.  
  144. SET_TARGET_PROPERTIES(UnfoldingTools PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  145.  
  146.  
  147.  
  148. #--------------------------#
  149. # Softwares
  150. IF(POPT_FOUND AND CIMG_FOUND)
  151.  
  152. # meshViewer
  153. ADD_EXECUTABLE(meshViewer ${SRC}/meshViewer.cpp)
  154. SET_TARGET_PROPERTIES(meshViewer PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  155. TARGET_LINK_LIBRARIES(meshViewer UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  156.  
  157. # maskViewer
  158. ADD_EXECUTABLE(maskViewer ${SRC}/maskViewer.cpp)
  159. SET_TARGET_PROPERTIES(maskViewer PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  160. TARGET_LINK_LIBRARIES(maskViewer UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  161.  
  162. # maskSaver
  163. ADD_EXECUTABLE(maskSaver ${SRC}/maskSaver.cpp)
  164. SET_TARGET_PROPERTIES(maskSaver PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  165. TARGET_LINK_LIBRARIES(maskSaver UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  166.  
  167. # simpleExample
  168. ADD_EXECUTABLE(simpleExample ${SRC}/simpleExample.cpp)
  169. SET_TARGET_PROPERTIES(simpleExample PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  170. TARGET_LINK_LIBRARIES(simpleExample UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  171.  
  172. # meshCropDisc
  173. ADD_EXECUTABLE(meshCropDisc ${SRC}/meshCropDisc.cpp)
  174. SET_TARGET_PROPERTIES(meshCropDisc PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  175. TARGET_LINK_LIBRARIES(meshCropDisc UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  176.  
  177. # distortImage
  178. ADD_EXECUTABLE(distortImage ${SRC}/distortImage.cpp)
  179. SET_TARGET_PROPERTIES(distortImage PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  180. TARGET_LINK_LIBRARIES(distortImage UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  181.  
  182. # circleSetConverter
  183. ADD_EXECUTABLE(circleSetConverter ${SRC}/circleSetConverter.cpp)
  184. SET_TARGET_PROPERTIES(circleSetConverter PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  185. TARGET_LINK_LIBRARIES(circleSetConverter UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  186.  
  187. # meshUnfolder
  188. ADD_EXECUTABLE(meshUnfolder ${SRC}/meshUnfolder.cpp)
  189. SET_TARGET_PROPERTIES(meshUnfolder PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  190. TARGET_LINK_LIBRARIES(meshUnfolder UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  191.  
  192. # meshTriangulator
  193. ADD_EXECUTABLE(meshTriangulator ${SRC}/meshTriangulator.cpp)
  194. SET_TARGET_PROPERTIES(meshTriangulator PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  195. TARGET_LINK_LIBRARIES(meshTriangulator UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  196.  
  197. # circleSetViewer
  198. ADD_EXECUTABLE(circleSetViewer ${SRC}/circleSetViewer.cpp)
  199. SET_TARGET_PROPERTIES(circleSetViewer PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  200. TARGET_LINK_LIBRARIES(circleSetViewer UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  201.  
  202. # mappingViewer
  203. ADD_EXECUTABLE(mappingViewer ${SRC}/mappingViewer.cpp)
  204. SET_TARGET_PROPERTIES(mappingViewer PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  205. TARGET_LINK_LIBRARIES(mappingViewer UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  206.  
  207. # meshInfos
  208. ADD_EXECUTABLE(meshInfos ${SRC}/meshInfos.cpp)
  209. TARGET_LINK_LIBRARIES(meshInfos UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  210.  
  211. # meshSelector
  212. ADD_EXECUTABLE(meshSelector ${SRC}/meshSelector.cpp)
  213. SET_TARGET_PROPERTIES(meshSelector PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  214. TARGET_LINK_LIBRARIES(meshSelector UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  215.  
  216. # meshCutter
  217. ADD_EXECUTABLE(meshCutter ${SRC}/meshCutter.cpp)
  218. SET_TARGET_PROPERTIES(meshCutter PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  219. TARGET_LINK_LIBRARIES(meshCutter UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  220.  
  221. # meshPatcher
  222. ADD_EXECUTABLE(meshPatcher ${SRC}/meshPatcher.cpp)
  223. SET_TARGET_PROPERTIES(meshPatcher PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  224. TARGET_LINK_LIBRARIES(meshPatcher UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  225.  
  226. # imageViewer
  227. ADD_EXECUTABLE(imageViewer ${SRC}/imageViewer.cpp)
  228. SET_TARGET_PROPERTIES(imageViewer PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  229. TARGET_LINK_LIBRARIES(imageViewer UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  230.  
  231. # computeBarycenter
  232. ADD_EXECUTABLE(computeBarycenter ${SRC}/computeBarycenter.cpp)
  233. SET_TARGET_PROPERTIES(computeBarycenter PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  234. TARGET_LINK_LIBRARIES(computeBarycenter UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  235.  
  236. # meshPruner
  237. ADD_EXECUTABLE(meshPruner ${SRC}/meshPruner.cpp)
  238. SET_TARGET_PROPERTIES(meshPruner PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  239. TARGET_LINK_LIBRARIES(meshPruner UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  240.  
  241. # example
  242. ADD_EXECUTABLE(example ${SRC}/example.cpp)
  243. SET_TARGET_PROPERTIES(example PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  244. TARGET_LINK_LIBRARIES(example UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  245.  
  246. # meshSmoother
  247. ADD_EXECUTABLE(meshSmoother ${SRC}/meshSmoother.cpp)
  248. SET_TARGET_PROPERTIES(meshSmoother PROPERTIES COMPILE_FLAGS "${SHARED_FLAGS} ${UnfoldingTools_flags}")
  249. TARGET_LINK_LIBRARIES(meshSmoother UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  250.  
  251. # meshNoiser
  252. ADD_EXECUTABLE(meshNoiser ${SRC}/meshNoiser.cpp)
  253. TARGET_LINK_LIBRARIES(meshNoiser UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  254.  
  255. IF(LIBXML2_LIBRARIES)
  256. # mScript
  257. ADD_EXECUTABLE(mScript ${SRC}/mScript.cpp ${SRC}/utils/ScriptInterpreter.cpp)
  258. TARGET_LINK_LIBRARIES(mScript UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  259. ENDIF(LIBXML2_LIBRARIES)
  260.  
  261.  
  262. IF(SWIG_DIR)
  263. # python binding
  264.  
  265. SET(UnfoldSoftware_LIBRARY_DIR ${PYTHON_OUTPUT_PATH})
  266. SET(CMAKE_CXX_FLAGS ${python_binding_flags})
  267. SET(CMAKE_SWIG_OUTDIR ${PYTHON_OUTPUT_PATH})
  268.  
  269. INCLUDE(${SWIG_USE_FILE})
  270.  
  271. FIND_PACKAGE(PythonLibs)
  272. INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
  273. SET(CMAKE_SWIG_FLAGS "")
  274.  
  275. SET_SOURCE_FILES_PROPERTIES(src/binding/UnfoldingTools.i PROPERTIES CPLUSPLUS ON)
  276. SET_SOURCE_FILES_PROPERTIES(src/binding/UnfoldingTools.i PROPERTIES SWIG_FLAGS "")
  277. SWIG_ADD_MODULE(unfolding_tools python src/binding/UnfoldingTools.i)
  278. SWIG_LINK_LIBRARIES(unfolding_tools ${PYTHON_LIBRARIES} UnfoldingTools ${LIBRARIES_CIMG} ${LIBRARIES_SOFTWARE})
  279. ENDIF(SWIG_DIR)
  280. ENDIF(POPT_FOUND AND CIMG_FOUND)
  281.  
  282.  
  283.  
  284. #--------------------------#
  285. # Documentation
  286. FIND_PACKAGE(Doxygen)
  287. IF(DOXYGEN)
  288. SET(HTML_DIR ${UnfoldSoftware_DOC_DIR}/html)
  289.  
  290. MAKE_DIRECTORY(${HTML_DIR})
  291. SET(UnfoldSoftware_DOCUMENTATION_INPUT_COMMON ".")
  292.  
  293. CONFIGURE_FILE(${UnfoldSoftware_SOURCE_DIR}/doxygen.config.in ${UnfoldSoftware_SOURCE_DIR}/doxygen.config IMMEDIATE)
  294.  
  295. ADD_CUSTOM_TARGET(doc ${DOXYGEN} ${UnfoldSoftware_SOURCE_DIR}/doxygen.config)
  296. ENDIF(DOXYGEN)
  297.  
  298. #-------------------------#
  299. # Edit
  300. ADD_CUSTOM_TARGET(edit emacs src/binding/*.i `find python/ -name "[!u]*.py"` `find . -name \"*.h\"` `find . -name \"*.cpp\"` ${CIMG_INCLUDE_DIR}/CImg.h&)
  301.  
RAW Paste Data