CMakeLists.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. cmake_minimum_required(VERSION 2.8)
  2. project(mcell C)
  3. add_definitions(-DPACKAGE_BUGREPORT="[email protected]")
  4. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
  5. # directories holding flex/bison files and out of source includes.
  6. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/deps)
  7. include_directories("${CMAKE_SOURCE_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}/deps" "${CMAKE_SOURCE_DIR}/include")
  8. # move config.h into place. Unix and Windows have different header files
  9. if (UNIX)
  10. file(COPY ${CMAKE_SOURCE_DIR}/src/config-nix.h DESTINATION
  11. ${CMAKE_CURRENT_BINARY_DIR}/deps)
  12. file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/deps/config-nix.h
  13. ${CMAKE_CURRENT_BINARY_DIR}/deps/config.h)
  14. elseif (WIN32)
  15. file(COPY ${CMAKE_SOURCE_DIR}/src/config-win.h DESTINATION
  16. ${CMAKE_CURRENT_BINARY_DIR}/deps)
  17. file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/deps/config-win.h
  18. ${CMAKE_CURRENT_BINARY_DIR}/deps/config.h)
  19. endif()
  20. # check for bison/flex and set up code gen
  21. find_package(BISON)
  22. find_package(FLEX)
  23. BISON_TARGET(mdlParser ${CMAKE_SOURCE_DIR}/src/mdlparse.y
  24. ${CMAKE_CURRENT_BINARY_DIR}/deps/mdlparse.c)
  25. # we need to hack around the current mdllex.l using sed which is targeted
  26. # toward autotools' ylwrap and won't work with flex proper
  27. #set_source_files_properties(mdllex_l PROPERTIES GENERATED true)
  28. find_program (SED_TOOL NAMES sed)
  29. if (NOT SED_TOOL)
  30. message( FATAL_ERROR "sed not found" )
  31. endif (NOT SED_TOOL)
  32. add_custom_command(
  33. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/deps/mdllex.l
  34. COMMAND ${SED_TOOL} -e "/^%option outfile/ d" ${CMAKE_SOURCE_DIR}/src/mdllex.l > ${CMAKE_CURRENT_BINARY_DIR}/deps/mdllex.l
  35. DEPENDS ${CMAKE_SOURCE_DIR}/src/mdllex.l
  36. VERBATIM)
  37. FLEX_TARGET(mdlScanner ${CMAKE_CURRENT_BINARY_DIR}/deps/mdllex.l
  38. ${CMAKE_CURRENT_BINARY_DIR}/deps/mdlex.c COMPILE_FLAGS -Crema)
  39. ADD_FLEX_BISON_DEPENDENCY(mdlScanner mdlParser mdllex_l)
  40. # create version.h target
  41. add_custom_command(
  42. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/deps/version.h
  43. COMMAND ${CMAKE_SOURCE_DIR}/src/version.sh > ${CMAKE_CURRENT_BINARY_DIR}/deps/version.h
  44. DEPENDS ${CMAKE_SOURCE_DIR}/src/version.sh
  45. VERBATIM)
  46. # check for needed libraries
  47. find_library(M_LIB m)
  48. set(CMAKE_C_FLAGS "-Wall -Wextra -Wshadow -Wno-unused-parameter -D_GNU_SOURCE=1 -O2 -std=c99${CMAKE_C_FLAGS}" )
  49. set(CMAKE_EXE_LINKER_FLAGS ${M_LIB})
  50. set(SOURCE_FILES
  51. src/api_test.c
  52. src/api_test.h
  53. src/argparse.c
  54. src/argparse.h
  55. src/chkpt.c
  56. src/chkpt.h
  57. src/config-nix.h
  58. src/config-win.h
  59. src/count_util.c
  60. src/count_util.h
  61. src/diffuse.c
  62. src/diffuse.h
  63. src/diffuse_trimol.c
  64. src/diffuse_util.c
  65. src/diffuse_util.h
  66. src/grid_util.c
  67. src/grid_util.h
  68. src/hashmap.h
  69. src/hashmap.c
  70. src/init.c
  71. src/init.h
  72. src/isaac64.c
  73. src/isaac64.h
  74. src/logging.c
  75. src/logging.h
  76. src/macromolecule.c
  77. src/macromolecule.h
  78. src/mcell.c
  79. src/mcell_init.c
  80. src/mcell_init.h
  81. src/mcell_misc.c
  82. src/mcell_misc.h
  83. src/mcell_objects.c
  84. src/mcell_objects.h
  85. src/mcell_react_out.c
  86. src/mcell_react_out.h
  87. src/mcell_reactions.c
  88. src/mcell_reactions.h
  89. src/mcell_release.c
  90. src/mcell_release.h
  91. src/mcell_run.c
  92. src/mcell_run.h
  93. src/mcell_species.c
  94. src/mcell_species.h
  95. src/mcell_structs.h
  96. src/mcell_surfclass.c
  97. src/mcell_surfclass.h
  98. src/mcell_viz.c
  99. src/mcell_viz.h
  100. src/mdlparse.y
  101. src/mdlparse_aux.h
  102. src/mdlparse_util.c
  103. src/mdlparse_util.h
  104. src/mem_util.c
  105. src/mem_util.h
  106. src/minrng.c
  107. src/minrng.h
  108. src/nfsim_func.h
  109. src/nfsim_func.c
  110. src/react.h
  111. src/react_cond.c
  112. src/react_outc.c
  113. src/react_outc_nfsim.c
  114. src/react_outc_trimol.c
  115. src/react_output.c
  116. src/react_output.h
  117. src/react_trig.c
  118. src/react_trig_nfsim.c
  119. src/react_nfsim.h
  120. src/react_util_nfsim.c
  121. src/react_util.h
  122. src/react_util.c
  123. src/rng.c
  124. src/rng.h
  125. src/sched_util.c
  126. src/sched_util.h
  127. src/strfunc.c
  128. src/strfunc.h
  129. src/sym_table.c
  130. src/sym_table.h
  131. src/triangle_overlap.c
  132. src/triangle_overlap.h
  133. src/util.c
  134. src/util.h
  135. src/vector.c
  136. src/vector.h
  137. src/version_info.c
  138. src/version_info.h
  139. src/viz_output.c
  140. src/viz_output.h
  141. src/vol_util.c
  142. src/vol_util.h
  143. src/volume_output.c
  144. src/volume_output.h
  145. src/wall_util.c
  146. src/wall_util.h)
  147. link_directories(${CMAKE_SOURCE_DIR}/lib)
  148. # build executable
  149. add_executable(mcell
  150. ${CMAKE_CURRENT_BINARY_DIR}/deps/version.h
  151. ${SOURCE_FILES}
  152. ${BISON_mdlParser_OUTPUTS}
  153. ${FLEX_mdlScanner_OUTPUTS})
  154. target_link_libraries(mcell ${M_LIB} nfsim_c NFsim)
  155. #set(CMAKE_EXE_LINKER_FLAGS "${M_LIB} -static-libgcc -static-libstdc++")
  156. #add_executable(mcell_static
  157. # ${CMAKE_CURRENT_BINARY_DIR}/deps/version.h
  158. # ${SOURCE_FILES}
  159. # ${BISON_mdlParser_OUTPUTS}
  160. # ${FLEX_mdlScanner_OUTPUTS})
  161. #target_link_libraries(mcell_static ${M_LIB} ${CMAKE_SOURCE_DIR}/lib/libnfsim_c_static.a ${CMAKE_SOURCE_DIR}/lib/libNFsim_static.a)