Salome HOME
Copyright update 2022
[modules/shaper.git] / src / ConstructionAPI / CMakeLists.txt
1 # Copyright (C) 2014-2022  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 email : webmaster.salome@opencascade.com
18 #
19
20 INCLUDE(Common)
21
22 SET(PROJECT_HEADERS
23   ConstructionAPI.h
24   ConstructionAPI_Axis.h
25   ConstructionAPI_Plane.h
26   ConstructionAPI_Point.h
27 )
28
29 SET(PROJECT_SOURCES
30   ConstructionAPI_Axis.cpp
31   ConstructionAPI_Plane.cpp
32   ConstructionAPI_Point.cpp
33 )
34
35 SET(PROJECT_LIBRARIES
36   ModelAPI
37   ModelHighAPI
38 )
39
40 INCLUDE_DIRECTORIES(
41   ${PROJECT_SOURCE_DIR}/src/Events
42   ${PROJECT_SOURCE_DIR}/src/ModelAPI
43   ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
44 )
45
46 # Plugin headers dependency
47 INCLUDE_DIRECTORIES(
48   # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers
49   ${PROJECT_SOURCE_DIR}/src/GeomAPI
50   # TODO(spo): it is for *_swig.h files. Can we eliminate it?
51   ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
52   ${PROJECT_SOURCE_DIR}/src/ConstructionPlugin
53 )
54
55 #TODO(spo): is ${OpenCASCADE_DEFINITIONS} necessary?
56 ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${OpenCASCADE_DEFINITIONS})
57 ADD_LIBRARY(ConstructionAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
58 TARGET_LINK_LIBRARIES(ConstructionAPI ${PROJECT_LIBRARIES})
59
60 # SWIG wrapper
61
62 INCLUDE(PythonAPI)
63
64 SET_SOURCE_FILES_PROPERTIES(ConstructionAPI.i PROPERTIES CPLUSPLUS ON)
65 SET_SOURCE_FILES_PROPERTIES(ConstructionAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
66
67 #TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)?
68 SET(SWIG_LINK_LIBRARIES
69   ConstructionAPI
70   ModelHighAPI
71   ModelAPI
72   ${PYTHON_LIBRARIES}
73 )
74
75 SET(CMAKE_SWIG_FLAGS -threads -w325,321,302,362,322,383,403)
76
77 SET(SWIG_MODULE_ConstructionAPI_EXTRA_DEPS ${SWIG_MODULE_ConstructionAPI_EXTRA_DEPS}
78   ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
79   doxyhelp.i
80   ${PROJECT_HEADERS}
81 )
82
83 IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
84   SWIG_ADD_LIBRARY(ConstructionAPI LANGUAGE python SOURCES ConstructionAPI.i ${PROJECT_HEADERS})
85 ELSE()
86   SWIG_ADD_MODULE(ConstructionAPI python ConstructionAPI.i ${PROJECT_HEADERS})
87 ENDIF()
88 SWIG_LINK_LIBRARIES(ConstructionAPI ${SWIG_LINK_LIBRARIES})
89
90 IF(WIN32)
91   SET_TARGET_PROPERTIES(_ConstructionAPI PROPERTIES DEBUG_OUTPUT_NAME _ConstructionAPI_d)
92 ENDIF(WIN32)
93
94 INSTALL(TARGETS _ConstructionAPI DESTINATION ${SHAPER_INSTALL_SWIG})
95 INSTALL(TARGETS ConstructionAPI DESTINATION ${SHAPER_INSTALL_BIN})
96 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ConstructionAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
97
98 # Tests
99
100 INCLUDE(UnitTest)
101
102 include(tests.set)
103
104 ADD_UNIT_TESTS(${TEST_NAMES})
105
106 if(${HAVE_SALOME})
107   enable_testing()
108   set(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/ConstructionAPI")
109   
110   install(FILES CTestTestfileInstall.cmake
111   DESTINATION ${TEST_INSTALL_DIRECTORY}
112   RENAME CTestTestfile.cmake)
113   install(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
114   
115   set(TMP_TESTS_NAMES)
116   foreach(tfile ${TEST_NAMES})
117     list(APPEND TMP_TESTS_NAMES "Test/${tfile}")
118   endforeach(tfile ${TEST_NAMES})
119   
120   install(FILES ${TMP_TESTS_NAMES} DESTINATION ${TEST_INSTALL_DIRECTORY})
121 endif(${HAVE_SALOME})