]> SALOME platform Git repositories - modules/shaper.git/blob - src/Config/CMakeLists.txt
Salome HOME
[Code coverage Config]: Unit test for Config_PropManager
[modules/shaper.git] / src / Config / CMakeLists.txt
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
7 ##
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 ## Lesser General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 INCLUDE(Common)
22 INCLUDE(UnitTest)
23 INCLUDE(XMLProcessing)
24 FIND_PACKAGE(SWIG REQUIRED)
25 INCLUDE(${SWIG_USE_FILE})
26
27 INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
28                      ${PYTHON_INCLUDE_DIR})
29
30 SET(PROJECT_HEADERS
31   Config_def.h
32   Config_FeatureMessage.h
33   Config_PluginMessage.h
34   Config_XMLReader.h
35   Config_ModuleReader.h
36   Config_FeatureReader.h
37   Config_Keywords.h
38   Config_WidgetAPI.h
39   Config_WidgetReader.h
40   Config_PointerMessage.h
41   Config_Common.h
42   Config_ValidatorMessage.h
43   Config_Prop.h
44   Config_PropManager.h
45   Config_AttributeMessage.h
46   Config_ValidatorReader.h
47   Config_DataModelReader.h
48   Config_Translator.h
49  )
50
51 SET(PROJECT_SOURCES
52   Config_FeatureMessage.cpp
53   Config_PluginMessage.cpp
54   Config_XMLReader.cpp
55   Config_ModuleReader.cpp
56   Config_FeatureReader.cpp
57   Config_WidgetAPI.cpp
58   Config_WidgetReader.cpp
59   Config_PointerMessage.cpp
60   Config_Common.cpp
61   Config_ValidatorMessage.cpp
62   Config_Prop.cpp
63   Config_PropManager.cpp
64   Config_AttributeMessage.cpp
65   Config_ValidatorReader.cpp
66   Config_DataModelReader.cpp
67   Config_Translator.cpp
68 )
69
70 SET(CMAKE_SWIG_FLAGS -threads -Wall)
71 SET_SOURCE_FILES_PROPERTIES(ConfigAPI.i PROPERTIES CPLUSPLUS ON)
72 SET_SOURCE_FILES_PROPERTIES(ConfigAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
73 SET(SWIG_SCRIPTS
74   ${CMAKE_CURRENT_BINARY_DIR}/ConfigAPI.py
75 )
76 SET(SWIG_LINK_LIBRARIES
77   Config
78   ${PYTHON_LIBRARIES}
79 )
80 IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
81   SWIG_ADD_LIBRARY(ConfigAPI LANGUAGE python SOURCES ConfigAPI.i ${PROJECT_HEADERS})
82 ELSE()
83   SWIG_ADD_MODULE(ConfigAPI python ConfigAPI.i ${PROJECT_HEADERS})
84 ENDIF()
85 SWIG_LINK_LIBRARIES(ConfigAPI ${SWIG_LINK_LIBRARIES})
86 IF(WIN32)
87   SET_TARGET_PROPERTIES(_ConfigAPI PROPERTIES DEBUG_OUTPUT_NAME _ConfigAPI_d)
88 ENDIF(WIN32)
89
90
91 SET(XML_RESOURCES
92   ${CMAKE_CURRENT_BINARY_DIR}/plugins.xml
93   dataModel.xml
94 )
95
96 SET(PROJECT_LIBRARIES
97     Events
98     ${LIBXML2_LIBRARIES}
99     ${PYTHON_LIBRARIES}
100 )
101
102 SOURCE_GROUP ("Resource Files" FILES ${XML_RESOURCES})
103
104 ADD_DEFINITIONS(-DCONFIG_EXPORTS -D_SCL_SECURE_NO_WARNINGS)
105 # -D_SCL_SECURE_NO_WARNINGS - to disable warnings 4996
106
107 ADD_LIBRARY(Config SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
108
109 TARGET_LINK_LIBRARIES(Config ${PROJECT_LIBRARIES})
110
111 # Prepare plugins.xml
112
113 # the solver to activate after installation
114 SET(DEFAULT_SOLVER "PlaneGCS")
115
116 # the list of all solvers
117 SET(SOLVERS "SolveSpace" "PlaneGCS")
118
119 # apply NO_<solver> variables
120 FOREACH(solver IN LISTS SOLVERS)
121   IF(NO_${solver})
122     LIST(REMOVE_ITEM SOLVERS ${solver})
123   ENDIF()
124 ENDFOREACH()
125
126 # check default solver in the list of solvers
127 LIST(FIND SOLVERS ${DEFAULT_SOLVER} INDEX)
128 IF(${INDEX} GREATER -1)
129   MESSAGE(STATUS "Default solver: ${DEFAULT_SOLVER}")
130 ELSE()
131   MESSAGE(FATAL_ERROR "Default solver: ${DEFAULT_SOLVER} is switched off.\nUnset NO_${DEFAULT_SOLVER} variable or define another default solver DEFAULT_SOLVER=<SOLVER> from the list: ${SOLVERS}.")
132 ENDIF()
133
134 # prepare variables for configuration
135 SET(DEFAULT_SOLVER "  <plugin library=\"${DEFAULT_SOLVER}Solver\"/>")
136 FOREACH(solver IN LISTS SOLVERS)
137   IF(DEFINED ALL_SOLVERS)
138     SET(ALL_SOLVERS "${ALL_SOLVERS}\n")
139   ENDIF()
140   SET(ALL_SOLVERS "${ALL_SOLVERS}  <plugin library=\"${solver}Solver\"/>")
141 ENDFOREACH()
142
143 # configuration
144 CONFIGURE_FILE(
145   "${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml.in"
146   "${CMAKE_CURRENT_BINARY_DIR}/plugins.xml"
147   )
148
149 INSTALL(TARGETS Config DESTINATION ${SHAPER_INSTALL_BIN})
150 INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
151
152 INSTALL(TARGETS _ConfigAPI DESTINATION ${SHAPER_INSTALL_SWIG})
153 INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})
154
155
156 ADD_UNIT_TESTS(
157   TestConfig.py
158 )