Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[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(XMLProcessing)
23 FIND_PACKAGE(SWIG REQUIRED)
24 INCLUDE(${SWIG_USE_FILE})
25
26 INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
27                      ${PYTHON_INCLUDE_DIR})
28
29 SET(PROJECT_HEADERS
30   Config_def.h
31   Config_FeatureMessage.h
32   Config_XMLReader.h
33   Config_ModuleReader.h
34   Config_FeatureReader.h
35   Config_Keywords.h
36   Config_WidgetAPI.h
37   Config_WidgetReader.h
38   Config_PointerMessage.h
39   Config_Common.h
40   Config_ValidatorMessage.h
41   Config_Prop.h
42   Config_PropManager.h
43   Config_AttributeMessage.h
44   Config_ValidatorReader.h
45   Config_DataModelReader.h
46   Config_Translator.h
47  )
48
49 SET(PROJECT_SOURCES
50   Config_FeatureMessage.cpp
51   Config_XMLReader.cpp
52   Config_ModuleReader.cpp
53   Config_FeatureReader.cpp
54   Config_WidgetAPI.cpp
55   Config_WidgetReader.cpp
56   Config_PointerMessage.cpp
57   Config_Common.cpp
58   Config_ValidatorMessage.cpp
59   Config_Prop.cpp
60   Config_PropManager.cpp
61   Config_AttributeMessage.cpp
62   Config_ValidatorReader.cpp
63   Config_DataModelReader.cpp
64   Config_Translator.cpp
65 )
66
67 SET(CMAKE_SWIG_FLAGS -threads -Wall)
68 SET_SOURCE_FILES_PROPERTIES(ConfigAPI.i PROPERTIES CPLUSPLUS ON)
69 SET_SOURCE_FILES_PROPERTIES(ConfigAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
70 SET(SWIG_SCRIPTS
71   ${CMAKE_CURRENT_BINARY_DIR}/ConfigAPI.py
72 )
73 SET(SWIG_LINK_LIBRARIES
74   Config
75   ${PYTHON_LIBRARIES}
76 )
77 SWIG_ADD_MODULE(ConfigAPI python ConfigAPI.i ${PROJECT_HEADERS})
78 SWIG_LINK_LIBRARIES(ConfigAPI ${SWIG_LINK_LIBRARIES})
79 IF(WIN32)
80   SET_TARGET_PROPERTIES(_ConfigAPI PROPERTIES DEBUG_OUTPUT_NAME _ConfigAPI_d)
81 ENDIF(WIN32)
82
83
84 SET(XML_RESOURCES
85   ${CMAKE_CURRENT_BINARY_DIR}/plugins.xml
86   dataModel.xml
87 )
88
89 SET(PROJECT_LIBRARIES
90     Events
91     ${LIBXML2_LIBRARIES}
92     ${PYTHON_LIBRARIES}
93 )
94
95 SOURCE_GROUP ("Resource Files" FILES ${XML_RESOURCES})
96
97 ADD_DEFINITIONS(-DCONFIG_EXPORTS -D_SCL_SECURE_NO_WARNINGS)
98 # -D_SCL_SECURE_NO_WARNINGS - to disable warnings 4996
99
100 ADD_LIBRARY(Config SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
101
102 TARGET_LINK_LIBRARIES(Config ${PROJECT_LIBRARIES})
103
104 # Prepare plugins.xml
105
106 # the solver to activate after installation
107 SET(DEFAULT_SOLVER "PlaneGCS")
108
109 # the list of all solvers
110 SET(SOLVERS "SolveSpace" "PlaneGCS")
111
112 # apply NO_<solver> variables
113 FOREACH(solver IN LISTS SOLVERS)
114   IF(NO_${solver})
115     LIST(REMOVE_ITEM SOLVERS ${solver})
116   ENDIF()
117 ENDFOREACH()
118
119 # check default solver in the list of solvers
120 LIST(FIND SOLVERS ${DEFAULT_SOLVER} INDEX)
121 IF(${INDEX} GREATER -1)
122   MESSAGE(STATUS "Default solver: ${DEFAULT_SOLVER}")
123 ELSE()
124   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}.")
125 ENDIF()
126
127 # prepare variables for configuration
128 SET(DEFAULT_SOLVER "  <plugin library=\"${DEFAULT_SOLVER}Solver\"/>")
129 FOREACH(solver IN LISTS SOLVERS)
130   IF(DEFINED ALL_SOLVERS)
131     SET(ALL_SOLVERS "${ALL_SOLVERS}\n")
132   ENDIF()
133   SET(ALL_SOLVERS "${ALL_SOLVERS}  <plugin library=\"${solver}Solver\"/>")
134 ENDFOREACH()
135
136 # configuration
137 CONFIGURE_FILE(
138   "${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml.in"
139   "${CMAKE_CURRENT_BINARY_DIR}/plugins.xml"
140   )
141
142 INSTALL(TARGETS Config DESTINATION ${SHAPER_INSTALL_BIN})
143 INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
144
145 INSTALL(TARGETS _ConfigAPI DESTINATION ${SHAPER_INSTALL_SWIG})
146 INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})