Salome HOME
update merge Coreflows and CDMATH compilation
[tools/solverlab.git] / CoreFlows / CMakeLists.txt
1 cmake_minimum_required (VERSION 3.1)
2 set(CMAKE_CXX_STANDARD 11)
3 set(CMAKE_CXX_STANDARD_REQUIRED ON)
4
5 # Project name
6 project (CoreFlows C CXX)
7 set (COREFLOWS_VERSION_MAJOR 0)
8 set (COREFLOWS_VERSION_MINOR 1)
9
10 option (COREFLOWS_WITH_DOCUMENTATION "Generate documentation for CoreFlows use." ON)
11 option (COREFLOWS_WITH_PYTHON "Compile Python interface for COREFLOWS." ON)
12 option (COREFLOWS_WITH_GUI "Compile Graphic user Interface for COREFLOWS." OFF)
13 option (COREFLOWS_WITH_PACKAGE "Generate RPM, Debian and tarball packages." OFF)
14
15 #Path to installed libraries
16 set (PETSC_DIR            OFF CACHE STRING "PETSc library path" )
17 set (SLEPC_DIR            OFF CACHE STRING "SLEPc library path" )
18
19 enable_testing()                                                                                           #
20 # Debug mode activates testing and profiling --------------------------------------------------------------#
21 if (CMAKE_BUILD_TYPE STREQUAL Debug)                                                                       #
22                                                                                                            #
23  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg --coverage")                                                  #
24  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg --coverage")                                    #
25  SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg --coverage")                              #
26                                                                                                            #
27 endif ()                                                                                                   #
28                                                                                                            #
29 #----------------------------------------------------------------------------------------------------------#
30
31 # Swig interface -------------------------------------------------------------------------------------------#
32                                                                                                             #
33 if (COREFLOWS_WITH_PYTHON)                                                                                  #
34    set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, python-dev, python-numpy, swig")     #
35    set (CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, python-devel, numpy, swig")              #
36    set (CoreFlows_SWIG_DIR ${CoreFlows_SOURCE_DIR}/swig)                                                    #
37 endif ()                                                                                                    #
38                                                                                                             #
39 #-----------------------------------------------------------------------------------------------------------#
40
41 # Base directories
42 set (CoreFlows_SRC ${CoreFlows_SOURCE_DIR}/Models ) 
43 set (CoreFlows_EXAMPLES ${CoreFlows_SOURCE_DIR}/examples)
44
45 set( CoreFlows_INCLUDES 
46   ${CDMATH_INCLUDES}                                                                                        #
47   ${PETSC_INCLUDES}                                                                                         #
48   ${CoreFlows_SRC}/inc                                                                                      #    
49   )                                                                                                         #
50
51 add_subdirectory (${CoreFlows_SRC})
52 add_subdirectory (${CoreFlows_EXAMPLES})
53 if (COREFLOWS_WITH_PYTHON)                                                                                  #
54    add_subdirectory (${CoreFlows_SWIG_DIR})                                                                 #
55 endif ()                                                                                                    #
56
57 # Documentation --------------------------------------------------------------------------------------------#
58                                                                                                             #
59 if (COREFLOWS_WITH_DOCUMENTATION)                                                                           #
60   configure_file (Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile  @ONLY IMMEDIATE)                              #
61   FILE(GLOB_RECURSE CoreFlows_Documentation ${CoreFlows_SOURCE_DIR}/Documentation *.dox)                    #
62   SET(Documentation_SRC                                                                                     #
63     ${PROJECT_BINARY_DIR}/Doxyfile                                                                          #
64     ${CoreFlows_Documentation}                                                                              #
65       )                                                                                                     #
66   add_custom_target (docCoreFlows COMMAND ${DOXYGEN_EXECUTABLE}                                                  #
67   SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)                                                                   #
68   install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION share/doc/CoreFlows OPTIONAL)                  #
69   INSTALL(FILES ${CoreFlows_SOURCE_DIR}/Documentation/CoreFlows.pdf DESTINATION share/doc/CoreFlows OPTIONAL)       #
70 endif ()                                                                                                    #
71                                                                                                             #
72 # ------------- --------------------------------------------------------------------------------------------#
73
74 # Graphic interface-----------------------------------------------------------------------------------------#
75                                                                                                             #
76 if (COREFLOWS_WITH_GUI)                                                                                                                                                                                                                                             #
77  set (CoreFlows_GUI_DIR ${CoreFlows_SOURCE_DIR}/gui)                                                        #
78  add_subdirectory(${CoreFlows_GUI_DIR})                 
79
80 endif ()                                                                                                    #
81                                                                                                             #
82 # ------------- --------------------------------------------------------------------------------------------#
83
84 #--------------------- COMPILATION MAIN --------------------------------------------------------------------#
85                                                                                                             #
86 INCLUDE_DIRECTORIES(                                                                                        #
87   ${CoreFlows_INCLUDES}                                                                                     #
88   )                                                                                                         #
89                                                                                                             #
90 SET(CoreFlowsMain_SOURCES                                                                                   #
91     ${CoreFlows_SRC}/src/Fluide.cxx                                                                         #
92     ${CoreFlows_SRC}/src/DiffusionEquation.cxx                                                              #
93     ${CoreFlows_SRC}/src/StationaryDiffusionEquation.cx                                                     #
94     ${CoreFlows_SRC}/src/ProblemFluid.cxx                                                                   #
95     ${CoreFlows_SRC}/src/IsothermalTwoFluid.cxx                                                             #
96     ${CoreFlows_SRC}/src/utilitaire_algebre.cxx                                                             #
97     ${CoreFlows_SRC}/src/DriftModel.cxx                                                                     #
98     ${CoreFlows_SRC}/src/SinglePhase.cxx                                                                    #
99     ${CoreFlows_SRC}/src/ProblemCoreFlows.cxx                                                               #
100     ${CoreFlows_SRC}/src/FiveEqsTwoFluid.cxx                                                                #
101     ${CoreFlows_SRC}/src/TransportEquation.cxx                                                              #
102   )                                                                                                         #
103                                                                                                             #
104 SET(MAIN_SOURCES                                                                                            #
105   main.cxx                                                                                                  #
106   )                                                                                                         #
107 SET(_extra_lib_CoreFlows ${CDMATH_LIBRARIES} ${PETSC_LIBRARIES} )                                           #
108 ADD_EXECUTABLE(CoreFlowsMainExe ${MAIN_SOURCES})                                                            #
109 SET_TARGET_PROPERTIES(CoreFlowsMainExe PROPERTIES COMPILE_FLAGS "")                                         #
110 TARGET_LINK_LIBRARIES(CoreFlowsMainExe CoreFlows  ${_extra_lib_CoreFlows})                                  #
111 INSTALL(TARGETS CoreFlowsMainExe DESTINATION bin/Executable)                                                #
112                                                                                                             #
113 configure_file(
114     ${PROJECT_SOURCE_DIR}/env_CoreFlows.sh
115     ${CMAKE_INSTALL_PREFIX}/env_CoreFlows.sh
116     @ONLY
117 )
118                                                                                                             
119                                                                                                             
120 # ------------- --------------------------------------------------------------------------------------------#
121
122
123 # Packaging
124 if (COREFLOWS_WITH_PACKAGE)
125   include (${CoreFlows_SOURCE_DIR}/CPackLists.txt)
126 endif ()