CMakeLists.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. cmake_minimum_required(VERSION 3.14)
  2. project(mcell)
  3. if ("${PYTHON_VERSION}" STREQUAL "")
  4. set(PYTHON_VERSION 3.9)
  5. endif()
  6. string(REPLACE "\." "" PYTHON_VERSION_NO_DOT ${PYTHON_VERSION})
  7. set(CMAKE_CXX_FLAGS "-DPYTHON_VERSION=${PYTHON_VERSION_NO_DOT}")
  8. set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION})
  9. find_package(Python3 ${PYBIND11_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development)
  10. message("-- Python3 include dirs are ${Python3_INCLUDE_DIRS}")
  11. include_directories(${Python3_INCLUDE_DIRS})
  12. add_definitions(-DPACKAGE_BUGREPORT="[email protected]")
  13. #TODO: unify case for cmake commands, e.g. set vs SET
  14. set(CMAKE_CXX_STANDARD 17)
  15. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  16. if(MSVC)
  17. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
  18. add_definitions(-DYY_NO_UNISTD_H)
  19. add_definitions(/EHsc)
  20. endif(MSVC)
  21. #set(CMAKE_CXX_EXTENSIONS OFF)
  22. # Using default gcc 8.3.0 provided in Debian 10
  23. # causes a segfault in nfSIM, however different gcc is ok
  24. if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 8.3.0)
  25. message(FATAL_ERROR
  26. "There is an error in nfSim, possibly due to a compiler issue, with gcc-8.3.0. "
  27. "Use a different compiler with CC=... and CXX=... "
  28. )
  29. endif()
  30. # add VTK libs VTK and headers
  31. set(VTK_DIR ${CMAKE_SOURCE_DIR}/../mcell_tools/work/build_vtk)
  32. find_package(VTK REQUIRED)
  33. # jsoncpp_test cannot be built with gperftools linking options
  34. add_subdirectory(${CMAKE_SOURCE_DIR}/libs/jsoncpp ${CMAKE_CURRENT_BINARY_DIR}/libs/jsoncpp)
  35. if (NOT WIN32)
  36. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 ")
  37. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 ")
  38. if (CMAKE_BUILD_TYPE STREQUAL "Release")
  39. # when -march=native or -march=haswell is enabled, there is some error in MCell3 wall
  40. # overlap detection, can be checked with mcell_tests_private/benchmarks/mdl/B4110_neuropil_no_custom_timestep
  41. # seems to be related to AVX2, maybe gcc issue
  42. # changing to sandybridge gives 2-6% in performance (in executed instructions), however
  43. # MCell does not work afterwards on machines such as Mac Mini 2018 with Intel i5
  44. set(OPTIMIZATION_FLAGS " -O3 -g -march=core2 -finline-limit=10000 ")
  45. # must not be used for pymcell (at least for now)
  46. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie ")
  47. endif()
  48. set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-deprecated-declarations")
  49. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  50. set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-ignored-optimization-argument")
  51. endif()
  52. set(INCLUDE_DIRS " -isystem ${CMAKE_SOURCE_DIR}/libs/")
  53. set(COMMON_C_CXX_FLAGS "${WARNING_FLAGS} -fPIC -g3 ${OPTIMIZATION_FLAGS} ${INCLUDE_DIRS} -D_GNU_SOURCE=1 ")
  54. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_CXX_FLAGS} -std=c11 ")
  55. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_C_CXX_FLAGS} -std=c++17 -fpermissive ")
  56. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lm -L ${CMAKE_CURRENT_BINARY_DIR}/libs/jsoncpp/src/lib_json")
  57. # special performance and debug options are not supported on Windows
  58. option(ENABLE_LTO "Use link-time optimization" OFF)
  59. option(ENABLE_GCOV "Use gcc coverage" OFF)
  60. option(ENABLE_GPROF "Use gprof profiling" OFF)
  61. option(ENABLE_GPERFTOOLS "Build with gperftools profiling" OFF)
  62. option(ENABLE_SANITIZER "Use address sanitizer" OFF)
  63. if (ENABLE_LTO)
  64. SET(CMAKE_AR "gcc-ar")
  65. SET(CMAKE_LD "gcc-ld")
  66. SET(CMAKE_RANLIB "gcc-ranlib")
  67. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto ")
  68. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto ")
  69. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto ")
  70. endif()
  71. if (ENABLE_GCOV)
  72. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage ")
  73. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage ")
  74. endif()
  75. if (ENABLE_GPROF)
  76. # gcc 6.3 generates PIC code by default, this does not work with gprof, -no-pie disables it
  77. SET(COMMON_PROFILING_FLAGS "-pg -no-pie -fno-omit-frame-pointer -finline-limit=20")
  78. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_PROFILING_FLAGS}")
  79. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_PROFILING_FLAGS}")
  80. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${COMMON_PROFILING_FLAGS}")
  81. endif()
  82. if (ENABLE_GPERFTOOLS)
  83. # build and install gperftools, for now it is done manually
  84. # using script build_gperftools.sh
  85. # then to run profiling
  86. # CPUPROFILE=./prof.out mcell
  87. # or
  88. # LD_PRELOAD='/mnt/code/src4/mcell/build/install_gperftools/lib/libprofiler.so' CPUPROFILE=./prof.out python model.py
  89. # pprof --text <app> ./prof.out # text output
  90. # pprof --gv <app> ./prof.out # graphical output, requires gv installed
  91. # (http://euccas.github.io/blog/20170827/cpu-profiling-tools-on-linux.html)
  92. # pybind11 ignores CMAKE_SHARED_LINKER_FLAGS so we must put the -L args to CXX flags as well
  93. SET(CMAKE_INCLUDE_GPERF_FLAGS "-L${CMAKE_CURRENT_BINARY_DIR}/libs/install_gperftools/lib/ -L${CMAKE_CURRENT_SOURCE_DIR}/build/install_gperftools/lib/")
  94. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITHGPERFTOOLS -I${CMAKE_CURRENT_BINARY_DIR}/libs/ ${CMAKE_INCLUDE_GPERF_FLAGS}")
  95. SET(CMAKE_LD_GPERF_FLAGS "${CMAKE_INCLUDE_GPERF_FLAGS} -lprofiler ")
  96. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LD_GPERF_FLAGS}")
  97. SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_LD_GPERF_FLAGS}")
  98. SET(GPERFTOOLS_LIB "profiler")
  99. else()
  100. SET(GPERFTOOLS_LIB "")
  101. endif()
  102. if (ENABLE_SANITIZER)
  103. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address ")
  104. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address ")
  105. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan ")
  106. endif()
  107. endif() # if (NOT WIN32)
  108. # directories holding flex/bison files and out of source includes.
  109. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/deps)
  110. include_directories(
  111. "${CMAKE_SOURCE_DIR}/src"
  112. "${CMAKE_SOURCE_DIR}/src4" all
  113. "${CMAKE_CURRENT_BINARY_DIR}/deps"
  114. "${CMAKE_SOURCE_DIR}/../nfsimCInterface/src/"
  115. "${CMAKE_SOURCE_DIR}/include"
  116. "${CMAKE_SOURCE_DIR}/../libbng/"
  117. "${CMAKE_SOURCE_DIR}/../libbng/libs/"
  118. "${CMAKE_SOURCE_DIR}/../libbng/libs/sparsehash/src/"
  119. "${CMAKE_SOURCE_DIR}/libs"
  120. "${CMAKE_SOURCE_DIR}/libmcell"
  121. # VTK - should be set by find_package but it does not work somehow...
  122. "${CMAKE_SOURCE_DIR}/../VTK/Common/DataModel/"
  123. "${VTK_DIR}/Common/DataModel/"
  124. "${CMAKE_SOURCE_DIR}/../VTK/Common/Core/"
  125. "${VTK_DIR}/Common/Core/"
  126. "${CMAKE_SOURCE_DIR}/../VTK/Common/Transforms/"
  127. "${VTK_DIR}/Common/Transforms/"
  128. "${CMAKE_SOURCE_DIR}/../VTK/Common/Math/"
  129. "${VTK_DIR}/Common/Math/"
  130. "${CMAKE_SOURCE_DIR}/../VTK/Filters/Core/"
  131. "${VTK_DIR}/Filters/Core/"
  132. "${CMAKE_SOURCE_DIR}/../VTK/Filters/Modeling/"
  133. "${VTK_DIR}/Filters/Modeling/"
  134. "${CMAKE_SOURCE_DIR}/../VTK/Filters/Sources/"
  135. "${VTK_DIR}/Filters/Sources/"
  136. "${CMAKE_SOURCE_DIR}/../VTK/Rendering/Core/"
  137. "${VTK_DIR}/Rendering/Core/"
  138. "${CMAKE_SOURCE_DIR}/../VTK/Rendering/Context2D/"
  139. "${VTK_DIR}/Rendering/Context2D/"
  140. "${CMAKE_SOURCE_DIR}/../VTK/Rendering/FreeType/"
  141. "${VTK_DIR}/Rendering/FreeType/"
  142. "${CMAKE_SOURCE_DIR}/../VTK/IO/Export/"
  143. "${VTK_DIR}/IO/Export/"
  144. "${CMAKE_SOURCE_DIR}/../VTK/IO/Image/"
  145. "${VTK_DIR}/IO/Image/"
  146. "${CMAKE_SOURCE_DIR}/../VTK/Common/ExecutionModel/"
  147. "${VTK_DIR}/Common/ExecutionModel/"
  148. "${CMAKE_SOURCE_DIR}/../VTK/Utilities/KWIML/"
  149. )
  150. # move config.h into place. Unix and Windows have different header files
  151. if (UNIX)
  152. configure_file(${CMAKE_SOURCE_DIR}/src/config-nix.h ${CMAKE_CURRENT_BINARY_DIR}/deps/config.h COPYONLY)
  153. elseif (WIN32)
  154. configure_file(${CMAKE_SOURCE_DIR}/src/config-win.h ${CMAKE_CURRENT_BINARY_DIR}/deps/config.h COPYONLY)
  155. endif()
  156. # check for bison/flex and set up code gen
  157. find_package(BISON)
  158. find_package(FLEX)
  159. BISON_TARGET(mdlParser ${CMAKE_SOURCE_DIR}/src/mdlparse.y
  160. ${CMAKE_CURRENT_BINARY_DIR}/deps/mdlparse.cpp)
  161. BISON_TARGET(dynGeomParser ${CMAKE_SOURCE_DIR}/src/dyngeom_parse.y
  162. ${CMAKE_CURRENT_BINARY_DIR}/deps/dyngeom_yacc.cpp)
  163. # the cmake flex plugin requires the flex file to be in the 'deps' directory
  164. configure_file(${CMAKE_SOURCE_DIR}/src/mdllex.l ${CMAKE_CURRENT_BINARY_DIR}/deps/mdllex.l COPYONLY)
  165. FLEX_TARGET(mdlScanner ${CMAKE_CURRENT_BINARY_DIR}/deps/mdllex.l
  166. ${CMAKE_CURRENT_BINARY_DIR}/deps/mdlex.cpp COMPILE_FLAGS -Cema)
  167. ADD_FLEX_BISON_DEPENDENCY(mdlScanner mdlParser mdllex_l)
  168. configure_file(${CMAKE_SOURCE_DIR}/src/dyngeom_lex.l ${CMAKE_CURRENT_BINARY_DIR}/deps/dyngeom_lex.l COPYONLY)
  169. FLEX_TARGET(dynGeomScanner ${CMAKE_CURRENT_BINARY_DIR}/deps/dyngeom_lex.l
  170. ${CMAKE_CURRENT_BINARY_DIR}/deps/dyngeom_lex.cpp COMPILE_FLAGS -Cema)
  171. ADD_FLEX_BISON_DEPENDENCY(dynGeomScanner dynGeomParser dyngeomlex_l)
  172. # create version.h target
  173. if (NOT WIN32)
  174. add_custom_target(
  175. version_h
  176. COMMAND ${CMAKE_SOURCE_DIR}/src/version.sh > ${CMAKE_CURRENT_BINARY_DIR}/deps/version.h
  177. DEPENDS ${CMAKE_SOURCE_DIR}/src/version.sh
  178. VERBATIM)
  179. elseif (WIN32)
  180. add_custom_target(version_h)
  181. add_custom_command(TARGET version_h COMMAND ${CMAKE_COMMAND} -E
  182. copy ${CMAKE_SOURCE_DIR}/appveyor_windows/version.h ${CMAKE_CURRENT_BINARY_DIR}/deps )
  183. endif()
  184. # linking on centos7 with 7.3.1 fails with undefined reference to `casc::detail::asc_NodeBase::~asc_NodeBase()'
  185. set(PYBIND11_LTO_CXX_FLAGS "")
  186. if (WIN32)
  187. # not compiling for now
  188. # add_subdirectory(${CMAKE_SOURCE_DIR}/libs/libunistd ${CMAKE_CURRENT_BINARY_DIR}/libs/libunistd)
  189. # include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/libs/libunistd/unistd)
  190. endif()
  191. add_subdirectory(${CMAKE_SOURCE_DIR}/libs/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/libs/pybind11)
  192. add_subdirectory(${CMAKE_SOURCE_DIR}/../libbng/ ${CMAKE_CURRENT_BINARY_DIR}/libs/libbng)
  193. add_subdirectory(${CMAKE_SOURCE_DIR}/../nfsim ${CMAKE_CURRENT_BINARY_DIR}/nfsim)
  194. add_subdirectory(${CMAKE_SOURCE_DIR}/../nfsimCInterface ${CMAKE_CURRENT_BINARY_DIR}/nfsimCInterface)
  195. add_subdirectory(${CMAKE_SOURCE_DIR}/libmcell ${CMAKE_CURRENT_BINARY_DIR}/libmcell)
  196. add_subdirectory(${CMAKE_SOURCE_DIR}/src4 ${CMAKE_CURRENT_BINARY_DIR}/src4)
  197. # set default locations of libraries and executables, must be done after add_subdirectory setups
  198. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin )
  199. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib )
  200. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/archives )
  201. # Second, for multi-config builds (e.g. msvc)
  202. foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  203. string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
  204. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR}/bin )
  205. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR}/lib )
  206. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR}/archives )
  207. endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
  208. set(SOURCE_FILES
  209. src/argparse.c
  210. src/chkpt.c
  211. src/count_util.c
  212. src/diffuse.c
  213. src/diffuse_trimol.c
  214. src/diffuse_util.c
  215. src/dyngeom.c
  216. src/dyngeom_parse_extras.c
  217. src/grid_util.c
  218. src/map_c.cpp
  219. src/init.c
  220. #src/isaac64.c
  221. src/logging.c
  222. src/mcell_dyngeom.c
  223. src/mcell_init.c
  224. src/mcell_misc.c
  225. src/mcell_objects.c
  226. src/mcell_react_out.c
  227. src/mcell_reactions.c
  228. src/mcell_release.c
  229. src/mcell_run.c
  230. src/mcell_species.c
  231. src/mcell_surfclass.c
  232. src/mcell_viz.c
  233. src/mem_util.c
  234. src/minrng.c
  235. src/nfsim_func.c
  236. src/react_cond.c
  237. src/react_outc.c
  238. src/react_outc_nfsim.c
  239. src/react_outc_trimol.c
  240. src/react_output.c
  241. src/react_trig.c
  242. src/react_trig_nfsim.c
  243. src/react_util.c
  244. src/react_util_nfsim.c
  245. #src/rng.c
  246. src/sched_util.c
  247. src/strfunc.c
  248. src/sym_table.c
  249. src/test_api.c
  250. src/triangle_overlap.c
  251. src/util.c
  252. src/vector.c
  253. src/version_info.c
  254. src/viz_output.c
  255. src/vol_util.c
  256. src/volume_output.c
  257. src/wall_util.c
  258. src/edge_util.c
  259. src/bng_util.cpp
  260. src/dump_state.cpp
  261. src/c_vector.cpp
  262. )
  263. set(SOURCE_FILES_ONLY_MCELL
  264. src/mcell.c
  265. src/mdlparse_util.c
  266. )
  267. SET_SOURCE_FILES_PROPERTIES( ${SOURCE_FILES} PROPERTIES LANGUAGE CXX )
  268. set( SOURCE_FILES ${SOURCE_FILES} src/mdlparse.y src/dyngeom_parse.y )
  269. SET_SOURCE_FILES_PROPERTIES( ${SOURCE_FILES_ONLY_MCELL} PROPERTIES LANGUAGE CXX )
  270. link_directories(${CMAKE_BINARY_DIR}/lib)
  271. # may be empty
  272. link_directories(${SYSTEM_PYTHON_LIB_DIR})
  273. if (UNIX)
  274. SET(CMAKE_INSTALL_RPATH "$ORIGIN/./lib")
  275. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  276. endif()
  277. INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/src")
  278. # copy tools for MDLr to MDL
  279. SET(MCELL_RULES_DIR ${CMAKE_SOURCE_DIR}/src/rules_py)
  280. configure_file(${MCELL_RULES_DIR}/grammar_definition.py ${CMAKE_CURRENT_BINARY_DIR}/grammar_definition.py COPYONLY)
  281. configure_file(${MCELL_RULES_DIR}/mcell3r.py ${CMAKE_CURRENT_BINARY_DIR}/mcell3r.py COPYONLY)
  282. configure_file(${MCELL_RULES_DIR}/mdlr2mdl.py ${CMAKE_CURRENT_BINARY_DIR}/mdlr2mdl.py COPYONLY)
  283. configure_file(${MCELL_RULES_DIR}/nfsim_python.py ${CMAKE_CURRENT_BINARY_DIR}/nfsim_python.py COPYONLY)
  284. configure_file(${MCELL_RULES_DIR}/postprocess_mcell3r.py ${CMAKE_CURRENT_BINARY_DIR}/postprocess_mcell3r.py COPYONLY)
  285. configure_file(${MCELL_RULES_DIR}/read_bngxml.py ${CMAKE_CURRENT_BINARY_DIR}/read_bngxml.py COPYONLY)
  286. configure_file(${MCELL_RULES_DIR}/read_mdl.py ${CMAKE_CURRENT_BINARY_DIR}/read_mdl.py COPYONLY)
  287. configure_file(${MCELL_RULES_DIR}/small_structures.py ${CMAKE_CURRENT_BINARY_DIR}/small_structures.py COPYONLY)
  288. configure_file(${MCELL_RULES_DIR}/split_bngxml.py ${CMAKE_CURRENT_BINARY_DIR}/split_bngxml.py COPYONLY)
  289. configure_file(${MCELL_RULES_DIR}/write_bngxmle.py ${CMAKE_CURRENT_BINARY_DIR}/write_bngxmle.py COPYONLY)
  290. configure_file(${MCELL_RULES_DIR}/write_mdl.py ${CMAKE_CURRENT_BINARY_DIR}/write_mdl.py COPYONLY)
  291. SET(MCELL_UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
  292. SET(BUILD_UTILS_DIR ${CMAKE_CURRENT_BINARY_DIR}/utils)
  293. configure_file(${CMAKE_SOURCE_DIR}/libmcell/generated/mcell.pyi ${BUILD_UTILS_DIR}/mcell.pyi COPYONLY)
  294. # copy tools for MDLr to MDL
  295. # TODO: list all files using configure_file
  296. file(COPY ${CMAKE_SOURCE_DIR}/../bionetgen/bng2/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bng2/)
  297. pybind11_add_module(mcell4_so MODULE
  298. # few files from mcell3 that are used
  299. # TODO: get rid of all deps except for the random generator
  300. src/logging.c
  301. src/mem_util.c
  302. src/strfunc.c
  303. src/util.c
  304. src/edge_util.c
  305. src/sym_table.c
  306. src/vector.c
  307. src/dump_state.cpp
  308. src/bng_util.cpp
  309. libmcell/api/exports.cpp
  310. )
  311. # for some reason MSVC searches for python library when linking utils although they should not need it
  312. get_filename_component(PYTHON_LIB_DIR ${Python3_LIBRARY_RELEASE} DIRECTORY)
  313. link_directories(${PYTHON_LIB_DIR})
  314. # build executable
  315. add_executable(mcell
  316. ${SOURCE_FILES}
  317. ${SOURCE_FILES_ONLY_MCELL}
  318. ${BISON_mdlParser_OUTPUTS}
  319. ${BISON_dynGeomParser_OUTPUTS}
  320. ${FLEX_mdlScanner_OUTPUTS}
  321. ${FLEX_dynGeomScanner_OUTPUTS})
  322. # mcell must be for backwards compatibility located in the root directory
  323. set_target_properties(mcell PROPERTIES
  324. RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
  325. RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
  326. RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}"
  327. RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}"
  328. )
  329. if (NOT WIN32 AND NOT APPLE)
  330. set(STDC_FS stdc++fs)
  331. endif()
  332. TARGET_COMPILE_DEFINITIONS(mcell PRIVATE NOSWIG=1)
  333. add_dependencies(mcell version_h mcell4)
  334. target_link_libraries(mcell
  335. mcell4 libmcell_dummy libbng nfsim_c_static NFsim_static jsoncpp_lib nauty ${VTK_LIBRARIES}
  336. )
  337. add_subdirectory(${CMAKE_SOURCE_DIR}/utils/data_model_to_pymcell)
  338. add_subdirectory(${CMAKE_SOURCE_DIR}/utils/)
  339. add_dependencies(mcell4_so libmcell mcell4 libbng jsoncpp_lib)
  340. target_link_libraries(mcell4_so
  341. PUBLIC libmcell
  342. PRIVATE mcell4 libbng jsoncpp_lib nauty ${VTK_LIBRARIES} ${GPERFTOOLS_LIB} ${GPERFTOOLS_MCELLSO_DEP} ${STDC_FS}
  343. PUBLIC libmcell # linking dependency issue, we must include limbcell once again to the list of libraries
  344. )
  345. set_property(TARGET mcell4_so PROPERTY POSITION_INDEPENDENT_CODE ON)
  346. set_target_properties(mcell4_so PROPERTIES PREFIX "")
  347. set_target_properties(mcell4_so PROPERTIES OUTPUT_NAME "mcell")
  348. if (WIN32)
  349. set_target_properties(mcell4_so PROPERTIES SUFFIX ".pyd")
  350. else()
  351. set_target_properties(mcell4_so PROPERTIES SUFFIX ".so") # must be .so on MacOS as well
  352. endif()