Salome HOME
Added a function Field::getFieldValues
[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 option (COREFLOWS_WITH_TESTS "Compile with testing and examples." ON)
15
16 #Path to installed libraries
17 set (PETSC_DIR            OFF CACHE STRING "PETSc library path" )
18 set (SLEPC_DIR            OFF CACHE STRING "SLEPc library path" )
19
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(CMAKE_BUILD_TYPE STREQUAL Debug)                                                                                             #
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(COREFLOWS_WITH_PYTHON)                                                                                                    #
38                                                                                                             #
39 #-----------------------------------------------------------------------------------------------------------#
40
41 # Base directories
42 set (CoreFlows_MODELS ${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_MODELS}/inc                                                                                           #    
49   )                                                                                                         #
50
51 add_subdirectory (${CoreFlows_MODELS})
52
53 # Tests
54 if   (COREFLOWS_WITH_TESTS)
55   enable_testing ()
56   add_subdirectory (${CoreFlows_EXAMPLES})#contains c++ and python tests
57 endif(COREFLOWS_WITH_TESTS)
58
59 if   (COREFLOWS_WITH_PYTHON)                                                                                  #
60    add_subdirectory (${CoreFlows_SWIG_DIR})                                                                 #
61 endif(COREFLOWS_WITH_PYTHON)                                                                                                    #
62
63 # Documentation --------------------------------------------------------------------------------------------#
64                                                                                                             #
65 if   (COREFLOWS_WITH_DOCUMENTATION)                                                                           #
66   configure_file (Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile  @ONLY IMMEDIATE)                              #
67   FILE(GLOB_RECURSE CoreFlows_Documentation ${CoreFlows_SOURCE_DIR}/Documentation *.dox)                    #
68   SET(Documentation_SRC                                                                                     #
69     ${PROJECT_BINARY_DIR}/Doxyfile                                                                          #
70     ${CoreFlows_Documentation}                                                                              #
71       )                                                                                                     #
72   add_custom_target (docCoreFlows COMMAND ${DOXYGEN_EXECUTABLE}                                                  #
73   SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)                                                                   #
74   install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION share/doc/coreflows-dev-doc OPTIONAL)                  #
75   INSTALL(FILES ${CoreFlows_SOURCE_DIR}/Documentation/CoreFlows.pdf DESTINATION share/doc OPTIONAL)         #
76 endif(COREFLOWS_WITH_DOCUMENTATION)                                                                                                    #
77                                                                                                             #
78 # ------------- --------------------------------------------------------------------------------------------#
79
80 # Standalone graphic interface-----------------------------------------------------------------------------------------#
81                                                                                                             #
82 if   (COREFLOWS_WITH_GUI)                                                                                                                   #
83   set (CoreFlows_GUI_DIR ${CoreFlows_SOURCE_DIR}/gui)                                                        #
84   add_subdirectory(${CoreFlows_GUI_DIR})
85 endif(COREFLOWS_WITH_GUI)                                                                                                    #
86                                                                                                             #
87 # ------------- --------------------------------------------------------------------------------------------#
88
89 #--------------------- COMPILATION MAIN --------------------------------------------------------------------#
90                                                                                                             #
91 INCLUDE_DIRECTORIES(                                                                                        #
92   ${CoreFlows_INCLUDES}                                                                                     #
93   ${PETSC_INCLUDES}
94   ${SLEPC_INCLUDES}
95   )                                                                                                         #
96                                                                                                             #
97 SET(MAIN_SOURCES                                                                                            #
98   mainCoreFlows.cxx                                                                                                 #
99   )                                                                                                         #
100 SET(_extra_lib_CoreFlows ${CDMATH_LIBRARIES} ${PETSC_LIBRARIES} )                                           #
101 ADD_EXECUTABLE(CoreFlowsMainExe ${MAIN_SOURCES})                                                            #
102 SET_TARGET_PROPERTIES(CoreFlowsMainExe PROPERTIES COMPILE_FLAGS "")                                         #
103 TARGET_LINK_LIBRARIES(CoreFlowsMainExe CoreFlowsLibs  ${_extra_lib_CoreFlows})                              #
104 INSTALL(TARGETS CoreFlowsMainExe DESTINATION bin)                                                   #
105                                                                                                             #
106 configure_file(
107     ${PROJECT_SOURCE_DIR}/env_CoreFlows.sh
108     @ONLY
109 )
110                                                                                                             
111                                                                                                             
112 # ------------- --------------------------------------------------------------------------------------------#
113
114
115 # Packaging
116 if   (COREFLOWS_WITH_PACKAGE)
117   include (${CoreFlows_SOURCE_DIR}/CPackLists.txt)
118 endif(COREFLOWS_WITH_PACKAGE)