]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add CMake flags DEFAULT_SOLVER, NO_SolveSpace & NO_PlaneGCS to switch solvers.
authorspo <sergey.pokhodenko@opencascade.com>
Fri, 25 Dec 2015 08:56:03 +0000 (11:56 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 25 Dec 2015 08:57:01 +0000 (11:57 +0300)
src/Config/CMakeLists.txt
src/Config/plugins.xml [deleted file]
src/Config/plugins.xml.in [new file with mode: 0644]
src/SketchSolver/CMakeLists.txt

index e43622f807b4300af9adf293dacffccb71fc0ec9..75cb0970339c0fb765869c226ed77c7967a96ecd 100644 (file)
@@ -45,7 +45,7 @@ SET(PROJECT_SOURCES
 )
 
 SET(XML_RESOURCES
-  plugins.xml
+  ${CMAKE_CURRENT_BINARY_DIR}/plugins.xml
   dataModel.xml
 )
 
@@ -64,5 +64,43 @@ ADD_LIBRARY(Config SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES}
 
 TARGET_LINK_LIBRARIES(Config ${PROJECT_LIBRARIES})
 
+# Prepare plugins.xml
+
+# the solver to activate after installation
+SET(DEFAULT_SOLVER "SolveSpace")
+
+# the list of all solvers
+SET(SOLVERS "SolveSpace" "PlaneGCS")
+
+# apply NO_<solver> variables
+FOREACH(solver IN LISTS SOLVERS)
+  IF(NO_${solver})
+    LIST(REMOVE_ITEM SOLVERS ${solver})
+  ENDIF()
+ENDFOREACH()
+
+# check default solver in the list of solvers
+LIST(FIND SOLVERS ${DEFAULT_SOLVER} INDEX)
+IF(${INDEX} GREATER -1)
+  MESSAGE(STATUS "Default solver: ${DEFAULT_SOLVER}") 
+ELSE()
+  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}.") 
+ENDIF()
+
+# prepare variables for configuration
+SET(DEFAULT_SOLVER "  <plugin library=\"${DEFAULT_SOLVER}Solver\"/>")
+FOREACH(solver IN LISTS SOLVERS)
+  IF(DEFINED ALL_SOLVERS)
+    SET(ALL_SOLVERS "${ALL_SOLVERS}\n")
+  ENDIF()
+  SET(ALL_SOLVERS "${ALL_SOLVERS}  <plugin library=\"${solver}Solver\"/>")
+ENDFOREACH()
+
+# configuration
+CONFIGURE_FILE(
+  "${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/plugins.xml"
+  )
+
 INSTALL(TARGETS Config DESTINATION bin)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
diff --git a/src/Config/plugins.xml b/src/Config/plugins.xml
deleted file mode 100644 (file)
index 77422df..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-<plugins module="PartSet">
-  <!-- Initialization plugin must be first here to initialize the PartSet document -->
-  <plugin library="InitializationPlugin"/>
-  <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
-  <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
-  <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
-  <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
-  <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
-  <plugin script="addons_Features" configuration="addons_Features.xml"/>
-  <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
-  <plugin library="ParametersPlugin" configuration="plugin-Parameters.xml"/>
-  <plugin library="SolveSpaceSolver"/>
-<!--  <plugin library="PlaneGCSSolver"/> -->
-  <plugin library="GeomValidators"/>
-  <plugin library="DFBrowser" internal="true"/>
-</plugins>
diff --git a/src/Config/plugins.xml.in b/src/Config/plugins.xml.in
new file mode 100644 (file)
index 0000000..af91d8f
--- /dev/null
@@ -0,0 +1,20 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugins module="PartSet">
+  <!-- Initialization plugin must be first here to initialize the PartSet document -->
+  <plugin library="InitializationPlugin"/>
+  <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
+  <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
+  <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
+  <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
+  <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
+  <plugin script="addons_Features" configuration="addons_Features.xml"/>
+  <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
+  <plugin library="ParametersPlugin" configuration="plugin-Parameters.xml"/>
+@DEFAULT_SOLVER@
+<!--
+@ALL_SOLVERS@
+-->
+  <plugin library="GeomValidators"/>
+  <plugin library="DFBrowser" internal="true"/>
+</plugins>
index 25c5a8c268f8074082a3aa81cfdd6674b5ffbdaa..91cfe6c82b8b73b866556b995730e6d09c810784 100644 (file)
@@ -77,10 +77,19 @@ INSTALL(TARGETS SketchSolver DESTINATION plugins)
 
 
 # Include specific solvers
-FIND_FILE(SSPath "SolveSpaceSolver/CMakeLists.txt" PATHS "${CMAKE_CURRENT_SOURCE_DIR}")
-STRING(COMPARE NOTEQUAL ${SSPath} "SSPath-NOTFOUND" SSPath_FOUND)
-FIND_FILE(GCSPath "PlaneGCSSolver/CMakeLists.txt" PATHS "${CMAKE_CURRENT_SOURCE_DIR}")
-STRING(COMPARE NOTEQUAL ${GCSPath} "GCSPath-NOTFOUND" GCSPath_FOUND)
+IF(NO_SolveSpace)
+  SET(SSPath_FOUND FALSE)
+ELSE()
+  FIND_FILE(SSPath "SolveSpaceSolver/CMakeLists.txt" PATHS "${CMAKE_CURRENT_SOURCE_DIR}")
+  STRING(COMPARE NOTEQUAL ${SSPath} "SSPath-NOTFOUND" SSPath_FOUND)
+ENDIF()
+
+IF(NO_PlaneGCS)
+  SET(GCSPath_FOUND FALSE)
+ELSE()
+  FIND_FILE(GCSPath "PlaneGCSSolver/CMakeLists.txt" PATHS "${CMAKE_CURRENT_SOURCE_DIR}")
+  STRING(COMPARE NOTEQUAL ${GCSPath} "GCSPath-NOTFOUND" GCSPath_FOUND)
+ENDIF()
 
 IF(${SSPath_FOUND} OR ${GCSPath_FOUND})
   IF(${SSPath_FOUND})